VIM as Python IDE

Finding the perfect IDE for Python isn’t an easy feat. There are a great many to chose from, but even though some of them offer really nifty features, I can’t help myself but feel attracted to VIM anyway. I feel that no IDE accomplishes the task of giving the comfort of complete power over the code – something is always missing out. This is why I always come back to using IDLE and VIM. Those two seem to be best companions when doing some quick and agile hacking – but when it comes to managing bigger and longer term projects, this combo needs some tweaking. But when it’s done, VIM will be a powerful IDE for Python – including code completion(with pydoc display), graphical debugging, task-management and a project view.

This is where we are going:

VIM as Python IDE

So, these are my thoughts on a VIM setup for coding (Python).

Modern GUI VIM implementations like GVIM or MacVIM give the user the opportunity to organize their open files in tabs. This might look convenient, but to me it is rather bad practice, because a second tab will not be in the in the same buffer scope as the first one which takes away from future interaction options between the two. Using MiniBufExplorer, however, gives the user tabs(not only in the GUI, but also in command line) and leaves the classic buffer interaction intact.

MiniBuf Explorer

Being able to neatly work on multiple files, the user still misses the potential his favourite IDE gives him in visualizing classes, functions and variables. Luckily there are quite a few plugins around to accomplish this task just as well. My favourite one would be TagList. TagList uses Exuberant Ctags for actually generating the tags(note: it really relies on this specific version of ctags – preinstalled implementations on UNIX systems won’t work).

TagList

A lot of coders have the habit of using TODO or FIXME statements in their code. Other IDEs often rely on having good third party project management software, but not VIM. There are great plugins like Tasklist reminding the programmer of those lines of code. Tasklist even implements custom lists – to me that’s an incredible productivity gain.

TaskList

In these times, the programmer knows his or her programming language more or less by interactively finding out what it can do. Therefore code completion(sometimes also called IntelliSense*ugh*) is a major feature. I have heard  many people saying that this is where VIM fails – but luckily they are plain wrong(; In V7, VIM introduced omni completion – given it is configured to recognize Python (if not, this feature is only a plugin away) Ctrl+x Ctrl+o opens a drop down dialog like any other IDE – even the whole Pydoc gets to be displayed in a split window.

Omni Completion

Probably the most wanted feature(besides code completion) is debugging graphically. VimPDB is a plugin that lets you do just that(. I acknowledge it is no complete substitution for a full fledged graphical debugger, but I honour the thought that having to rely on a debugger (often), is a hint of bad design.

VimPDB

From the eye-candy to the implementation. Don’t worry, it’s no sorcery.

First of all, make sure you have VIM version 7.x installed, compiled with Python support. To check for the second, enter :python print “hello, world” into VIM. If you see an error message like “E319: Sorry, the command is not available in this version”, then it’s time to get a new one. If you’re on a Mac, just install MacVIM(there’s also a binary for the console in /Applications/MacVim.app/Contents/MacOS/). If you’re on Windows, GVIM will suffice(for versions != 2.4 search for the right plugin). If you’re on any other machine, you will probably know how to compile your very own VIM with Python support.

Second, check if you have a plugin directory. In Unix it would typically be located in $HOME/.vim/plugin, in Windows in the Program Files directory. If it doesn’t exist, create it.

Now, let’s start with the MiniBufExplorer. Get it and copy it into your plugin directory. To start it automatically when needed and be able to use it with keyboard and mouse commands, append these lines in your vimrc configuration:

let g:miniBufExplMapWindowNavVim = 1
let g:miniBufExplMapWindowNavArrows = 1
let g:miniBufExplMapCTabSwitchBufs = 1
let g:miniBufExplModSelTarget = 1

For a project view, get TagList and Exuberant Ctags. To install Ctags, unpack it, go into the directory and do a compile/install via:

./configure && sudo make install

Ctags will then be installed in /usr/local/bin. When using a Windows machine, I recommend Cygwin with GCC and Make; it’ll work just fine. If you don’t want to tamper with your original ctags installation, you can propagate the location to VIM by appending the following line to vimrc:

let $Tlist_Ctags_Cmd='/usr/local/bin/ctags'

To install TagList, just drop it into VIMs plugin directory. You will now be able to use the project view by typing the command :TlistToggle.

Tasklist is a simple plugin, too. Copying it into the plugin directory will suffice. I like to have shortcuts and have added

map T :TaskList<CR>
map P :TlistToggle<CR>

to vimrc. Pressing T will then open the TaskList if there are any tasks to process. q quits the TaskList again.

VimPDB is a plugin, as well. Install as before and see the readme for documentation. If it doesn’t work out of the box, watch for the known issues.

To enable code(omni) completion, add this line to your vimrc:

autocmd FileType python set omnifunc=pythoncomplete#Complete

If it doesn’t work then, you’ll need this plugin.

My last two recommondations are setting these lines to comply to PEP 8(Pythons’ style guide) and to have decent eye candy:

set expandtab
set textwidth=79
set tabstop=8
set softtabstop=4
set shiftwidth=4
set autoindent
:syntax on

There are certainly a lot more flags to help productivity, but those will probably be more user specific.

Have fun coding Python while not being bound to a specific IDE, but having all the benefits of VIM bundled with a few helping hands. Enjoy, everyone.

If you liked this article, please feel free to re-tweet it and let others know.


    You should follow me on twitter here
twitter_preek

Category: articles | Tags: , , , , , , , , , , , , , , , , 121 comments »

121 Responses to “VIM as Python IDE”

  1. VIM as Python IDE | Alain M. Lafon « Netcrema - creme de la social news via digg + delicious + stumpleupon + reddit

    […] VIM as Python IDE | Alain M. Lafon […]

  2. popurls.com // popular today

    popurls.com // popular today…

    story has entered the popular today section on popurls.com…

  3. Twitted by preek

    […] This post was Twitted by preek – Real-url.org […]

  4. pekuja

    You don’t actually need MiniBufExplorer to get tabs in Vim. Vim 7 comes with tab support built right in! Just :tabe myfile to edit a file in a new tab, then :tabp and :tabn to switch between tabs.
    There’s a little tutorial that explains more about using the feature at: http://www.linux.com/archive/articles/59533

  5. Alain M. Lafon

    Hiho pekuja,
    you’re right, tabs are built in nowadays. But if you’re using those, using buffers will be quite uncomfortable. Your tab-names will keep changing and ultimately you’ll lose oversight. With MiniBuf everything keeps in place.
    Best,
    Alain

  6. mark

    Thanks, in particular for taglist, that’ll make things easier.
    Technically your settings for PEP8 conformance are incorrect, instead you should use:
    set tabstop=8
    set expandtab
    set softtabstop=4
    set shiftwidth=4
    set textwidth=79
    the difference being that the actual tab character is still eight columns wide (as specified by the python language), but using the tab key, backspace and indent/deindent ( keys) will correctly shift you by 4 spaces.

  7. steve

    I’m so glad I don’t code in a language that requires soft-tabs

  8. Alain M. Lafon

    @Mark.
    You’re absolutely right – I have corrected it right away. Thanks for the advice.

  9. Alain M. Lafon

    @Steve
    Well.. requires probably isn’t quite that right. To quote PEP 8:
    “The most popular way of indenting Python is with spaces only. The second-most popular way is with tabs only.”

  10. NexNova » Blog Archive » Links del giorno: May 24, 2009

    […] VIM as Python IDE | Alain M. Lafon […]

  11. Bomif

    Hey Alain,

    much respect for ur article, u really didn’t need to complete studies with the rest of us like it seems :)

    Good luck for ur future

    Manuel

  12. links for 2009-05-24 at DeStructUred Blog

    […] VIM as Python IDE | Alain M. Lafon (tags: python Vim programming IDE tips howto) […]

  13. Daelin the Cruel

    God, that image zoom script is SLOW!

  14. Alain M. Lafon

    @Daelin
    Sorry to say, but that would be your machine. My server is on gigabit, so it should feed you the images quick enough. And it work’s on my workstation.
    I hope you enjoyed the article, anyways. Take care Mr. Cruel.

  15. Shannon -jj Behrens

    I’m a Vim diehard, but I’ve really been enjoying NetBeans with the jVi plugin. It feels like Vim, but has the additional benefits of an IDE. Being a Vim fanatic, I didn’t really fully understand those benefits until I tried it out for a few days.

    http://jjinux.blogspot.com/2009/01/ide-netbeans.html

    http://jjinux.blogspot.com/2009/01/vim-jvi.html

  16. Geek Stuff: VIM als Python IDE – Der Schockwellenreiter

    […] sich den VIM zurechtgelegt hat, bastelt sich auch eine Python-IDE damit. So auch Alain M. Lafon: VIM as Python IDE. Mein Editor meines Vertrauens ist ja bekanntlich TextWrangler, der freie (frei wie Freibier) […]

  17. Alain M. Lafon

    @Shannon-jj Behrens
    Hi there,
    as a former Sun employee(back in the days.. before Oracle*urgh*), I am quite familiar with Netbeans and jVi. To say the truth, I never felt quite satisfied with the Vi implementation there and always went back to plain Netbeans.
    However, Netbeans is no option, because Python is not supported. There’s a team working on it, but it’s far from being usable at the moment.
    Thanks for your comment and congrats to the storks present(;

  18. » Vim come IDE per Python

    […] Via | Dispatched […]

  19. Shannon -jj Behrens

    Alain, I too worked at Sun–very long ago.

    jVi is definitely not perfect, but it’s the best Vi emulation that I’ve ever used. Most Vi emulators drive me nuts (for instance, the Vi emulation in WingIDE or KomodoEdit), perhaps because I prefer Vim. I guess jVi is close enough that it doesn’t drive me nuts.

    I like all the other goodies I get with NetBeans. I still use Vim in those cases where NetBeans isn’t helpful.

    Can you tell me more about why you prefer MiniBufExplorer over tabs? I used to use MiniBufExplorer, but when tabs came out, I switched to those instead. I create a new tab for every file (using :tabedit filename), and I even have a shell alias (gvim –remote-tab filename) so that I can open up a file in a new tab from the shell. Hence, I follow the one tab for every file rule, and I never get confused. Can you walk me through why MiniBufExplorer is better?

    > Thanks for your comment and congrats to the storks present(;

    Thanks! :)

  20. Shannon -jj Behrens

    > However, Netbeans is no option, because Python is not supported.

    Why do you say that? http://www.netbeans.org/features/python/index.html

    It might not be quite as polished as WingIDE (which really, really understand Python), but it’s not bad at all. (I prefer NetBeans over WingIDE because I also have to code HTML, CSS, JavaScript, PHP, Ruby, etc.

    IntelliSense, warnings, documentation, etc. all work: http://jjinux.blogspot.com/2009/01/ide-netbeans.html

  21. Shannon -jj Behrens

    > Netbeans is no option, because Python is not supported.

    Why do you say that? See http://www.netbeans.org/features/python/index.html.

    I think it works fairly well with Python. See http://jjinux.blogspot.com/2009/01/ide-netbeans.html. Autocomplete, tags, previewing documentation, etc. all work. It’s not perfect yet, since Python support is fairly new, but it’s definitely workable. I like the way it even tells me when I’m doing stupid things like unused imports, etc.

  22. Alain M. Lafon

    Welcome, then, former Sunny. It really is a good feeling to have you write comments here, even though I don’t post under blogs.sun.com anymore(;

    I think you are perfectly right, VI emulation in commercial editors is especially bad implemented – there’s no way I could use them seriously. And while jVi might not be a bad implementation, Netbeans felt obstructed to me anyway. I just felt the workflow being interrupted by it, even though I really gave it a weeks try. Personally, I didn’t experience that much a gain, but limited in the use of Netbeans’ internal features. Certainly that’s a very personal opinion – maybe boosted, because I prefer VIM over VI, too.

    The MiniBuf over Tabs preference, however, is a objectively measurable reason. If you work with legacy software (like TagList which I have described in the article), they will most likely work with buffers, not tabs. Of course tabs share a buffer namespace(I wrote they didn’t, but I chose this phrasing to not confuse a beginner even more), but in a very jumbling way.
    Say you open file A and B in tabs. While still working in tab A, you do :bNext. You will have your second buffer/file opened, but your tabs will now display B and B – buffer/file A isn’t lost, but you can’t see or click it anymore.
    Of course this example is constructed, because the right way to change tabs is :tabNext, but when you use Vimscripts, they often use buffers and will therefore produce a lot of confusion on the screen.

    The -remote-tab feature is certainly nice, indeed. But I try to get along and use the mouse sometime. In GVim dragging a new file in the GUI will result in opening it in a new buffer – MiniBuf will create a new tab for me and everything moves along smoothly.

  23. Alain M. Lafon

    Well, I say that, because Netbeans for Python is still in Alpha/(Beta?). Only last week I tried it again – all I did was a “Hello, world” mockup with a single variable which I tried to debug. While doing that, Netbeans crashed. Besides Jython took like.. a minute or so to power up on my Core2Duo machine.
    I tried it once before, then the debugger worked, but well.. it gave me the whole Jython stacktrace – finding my variables was more confusing than in a J2EE app^^ And then.. it crashed, too.

    I’ll certainly give it more tries in the future, because I really like Netbeans and feel very comfortable using it in my J2SE, J2EE and RoR apps. But for the moment, I will respect the tag “early access”.

    Your article seems to imply that it works for you better, than it did for me, though. I haven’t read it yet – I should get ready for work where I will have the time to do so^^

    But even if it did work, the features you named (autocomplete, preview pydoc, unused imports..) are all available in VIM, too. Autocomplete and preview via OmniComplete and unused imports via PyFlakes, for example.
    I don’t know fore sure as of now, but probably I’ll stick with VIM for Python even if Netbeans will support Python as it does Ruby. Imho Python doesn’t need as much IDE comfort as other languages(like Java). I think I gain more performance in being able to completely configure my IDE – use custom snippets, chose a well suited color scheme for the current daylight, even write my own Vimscripts using Python(;

    Besides, my last reasoning will always be, that I can use VIM on servers(my own as well as from clients). My server is running Solaris 10 and my prefered access is via SSH. And on a clients server, there’s always the need for a quickfix(yeah, I know it’s bad practice – but it’s not always my code or choice^^).

  24. Philluminati

    Excellent article!

    Also I found out today you can do :set mouse=a which gives you the ability to click to position the cursor and visual selection with the cursor which is very cool.

    This aught to be posted to the Vim reddit purely so it “lives longer” there and becomes a better knowledge base for vim,

  25. kilowatt

    /shameless self-plug[in]

    With pyflakes-vim, vim will check your code on the fly for obvious errors. You never have to check in a NameError typo again :p

    http://www.vim.org/scripts/script.php?script_id=2441

  26. talklittle

    Whoa nice article, I didn’t know about omni completion. I’d been trying to tell myself that not having intellisense is a good thing in some ways, but pshh yeah right, I’m thrilled to learn that vim has it.

  27. adamzap

    this set of cheat sheets is a great way to learn vim. master one at a time

    http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html

  28. erlanger

    My favorite Vim customization for Python coding:

    :nnoremap :w !python

    Also works for PHP

    :nnoremap :w !php

    You put these in the respective ftplugin files.

  29. wooby

    Similar setup for PHP: http://gravitonic.com/files/talks/php-quebec-2009/vim-for-php-programmers.pdf

  30. slmbrhrt

    grr, formatting.

    http://ed.cranford.googlepages.com/vimrc if you’re really interested in seeing my vimrc. I’m not fond of plugins.

  31. Shannon -jj Behrens

    Alain,

    Yeah, NetBeans definitely works better for me than it does for you. It’s never crashed on me, and it doesn’t take a minute to start. Perhaps the difference is that I don’t use Jython–Jython’s slow.

    As for the coolness of Vim, you don’t have to convince me! I’ve been using Vim as my main editor for years, and I consider myself a low-level expert. I only switched to NetBeans because I was burnt out and was looking for ways to “mix it up”.

    As for your mouse problem, if I really needed to do that, I would do :tabnew and then drag the file to the window.

    I agree that Python doesn’t need an IDE–which is one of the reasons I use it ;) I also use Vim when logging into remote servers. However, there’s nothing wrong with using something more friendly when editing locally.

    Thanks for the heads up about pyflakes-vim. I knew about it, but had never tried it.

    I use TagList, and it seems to work just fine with tabs.

    One thing I really like about tabs in Vim on my Mac is that tabs work the same in the shell, in Vim, and in Firefox. That’s a huge win because I have the hot keys (Apple-Shift-{ and Apple-Shift-}) memorized.

    I rarely use bNext, so I don’t encounter the problem you mentioned. If I do need to operate on multiple buffers instead of tabs (for instance if I pass multiple files on the command line), I open up another window. In general, I stick to the one buffer per one tab rule, so things make sense.

    I haven’t tried to debug anything in NetBeans. I always use pdb in the shell for some reason, perhaps because I don’t know how to connect the debugger to my Web server process.

    I’ve used Vim for about 10 years now at a pretty advanced level. However, as part of my plan to recover from burnout, I decided to open my mind a bit. As much as I like Vim, the fact of the matter is that you’re better off using Emacs for Lisp, Erlang, and Oz. You’re better off using IntelliJ or NetBeans for Java. I think editing CSS and JavaScript in NetBeans is nicer than in Vim. Fortunately, Python is easy to work with in a range of editors and IDEs. I still use Vim as my main editor and for editing my TODO file which I keep in outline form (I love the VimOutliner plugin).

    I’m trying to be less religious about it these days and be more pragmatic. That’s why I like the jVi plugin so much. It was written by a fellow Vim fanatic, so I can use NetBeans without having to learn a new keyset. Although, apparently, it works better for me than for you.

    Happy Hacking!
    -jj

  32. Shannon -jj Behrens

    I have a few more tips. I like different indentation settings for different languages, so I have the following:

    augroup vimrc
    au!
    autocmd FileType css setlocal sw=4 sts=4 et
    autocmd FileType eruby setlocal sw=2 sts=2 et
    autocmd FileType haskell setlocal sw=4 sts=4 et
    autocmd FileType htmlcheetah setlocal sw=2 sts=2 et
    autocmd FileType html setlocal sw=2 sts=2 et
    autocmd FileType javascript setlocal sw=2 sts=2 et
    autocmd FileType java setlocal sw=4 sts=4 et
    autocmd FileType mason setlocal sw=2 sts=2 et
    autocmd FileType ocaml setlocal sw=2 sts=2 et
    autocmd FileType perl setlocal sw=4 sts=4 et
    autocmd FileType php setlocal sw=4 sts=4 et
    autocmd FileType python setlocal sw=4 sts=4 et tw=72
    autocmd FileType ruby setlocal sw=2 sts=2 et
    autocmd FileType scheme setlocal sw=2 sts=2 et
    autocmd FileType sql setlocal et
    autocmd FileType text setlocal sw=2 sts=2 et tw=79
    augroup END

    Note, I set tw=72 for Python because the PEP 8 says that comments should be wrapped at 72 columns.

    To use tags more completely:

    Setup:
    Install exuberant-ctags.
    :cd project_root
    :!ctags -R .
    :set tags=tags
    Jump to the definition of the symbol under the cursor:
    ^]
    Go back to where you were:
    ^o

    I still think NetBeans’ autocomplete is better and WingIDE’s is best, but to tell you the truth, one of my favorite things in Vim is ^n which will finish typing whatever word you were currently typing based on other words in the current buffer. ^n works everywhere. It’s super stupid, and super useful.

  33. Shannon -jj Behrens

    Hmm, I wanted to try out pyflakes.vim, but it looks like MacVim comes compiled with Python 2.3 so pyflakes.vim crashes horribly. Can anyone else confirm this?

  34. What text editor is everyone using for Python - Page 4 | keyongtech

    […] | > `

  35. Tor Norbye

    Don’t get the NetBeans Python “EA” access bits from here:
    http://www.netbeans.org/features/python/index.html

    Those bits are really really old (as in 6 months or more). There’s a lot of new functionality, and many fixes, since then. I think the development update centers have up to date bits, if not, you can grab a kit here:
    http://deadlock.netbeans.org/hudson/job/python/

    For some of the features added since then, see
    http://blogs.sun.com/tor/category/NetBeans
    (scroll past the first entry on JavaScript) — code coverage, test runner, type assertions, etc.

    — Tor

  36. Shannon -jj Behrens

    Hmm, I’m also having a problem with minibufexpl. If I’m editing a Vim outline file, I can’t use ^k to jump to the window with the buffer list. It says something about “no TAGS file”. It works just fine when editing other types of files. Weird. I can’t use ^up either since my Mac switches to a different space (i.e. virtual desktop) when I do that. ^tab works, but that’s painful. Hmm. There’s definitely a benefit to having Vim tabs behave like tabs in Terminal.app and Firefox :-/ I wonder if there’s a Vim setting to enforce the rule of one tab per writable buffer, which I enforce informally.

  37. VIM as Python IDE | Wisdom and Wonder

    […] Here is a nice article about using VIM as a Python IDE. […]

  38. drozzy

    Why can’t all of this be BUILT-IN into Vim?
    Really – why must I much arund with all these plugin that don’t work together half of the time… how hard would it be to just integrate it into the vim installer?

    Or at least make some kind of central repo for an easier way of installing them, something like apt-get:

    vim install package-name

  39. Alain M. Lafon

    Well, that one is easy. VIM already ships with a ton of features built-in, which make it one of the greatest editors around. But on top of that VIM is able to provide a framework for job-related customization. It doesn’t matter if you need to write your next paper in LaTex/Roff, if you’re a sys admin and confronted with logs, if you’re not satisfied with your installed pagers(less/more), if you need to extend your other applications(like mutt), if you’re writing C or in this case Python. It doesn’t enforce a certain feature-set like the big IDEs, it doesn’t wedge you into a macro-world of possibilities, but rather opens up all the opportunities – like every other good UNIX derived tool.
    Besides.. since you implied you were using Debian; there’s a vim-addon-manager and a script collection of giving VIM bells and whistles. So, enjoy VIM the Debian way(;

  40. Alain M. Lafon

    Thanks Tor,
    that’s a really nice hint. Last week I got Eric4 to fully work on WinXP thanks to a dear friend of mine. It really makes a good impression on me. But as of now – I’ll stick to VIM while refactoring (with the Bicycle Repair Man).

  41. Alain M. Lafon

    @Shannon
    I can confirm that PyFlakes doesn’t work on stock MacVIM. That one is compiled with Python 2.3, because it also has to run on legacy OSX systems for some strange reason.. Building your own VIM isn’t too difficult though(stretching my knowledge a little bit here since I haven’t done it on a Mac until now). You could try using PySmell for example.

  42. Alain M. Lafon

    @Shannon
    Thanks for your additional configuration.
    Thinking of autocomplete; my opinion is that not much beats VIM with the SuperTab plugin, though.

  43. Alain M. Lafon

    @Shannon
    I agree on a lot of your comments – I try not to be religious on most things nowadays, too. Well.. I quit my job at Sun working with cool Sparc machines, Solaris, DTrace to do commercial business software running on XP “servers” – that’s hard to beat, I guess. I also agree that Netbeans is simply the best when it comes to Java, especially since version 6.x; I want to add Ruby on Rails to that list, too.
    But what I want to add is one of my main reason for using VIM whenever possible – speed. I’m that kind of guy working with 20 windows and as many workspaces at once, I’m opening and closing files all the time. That might sound unprofessional and non-focused, but it works for me nice. I like usability and feel a lot more than a definite better feature set. I won’t argue that there are pros for Emacs and Netbeans, but darn are they slow compared to VIM – that’s a no-go for me in daily work. And then there’s one last thing – size. When I’m not at home or at work, I use a 13″ Macbook – using a full blown IDE like Netbeans then leaves me with as much as 8x10cm space for coding.

  44. Shannon -jj Behrens

    I agree with your comments regarding speed and size. I too love to open tons of Vim windows with tons of tabs. I too have a 13″ MacBook, and NetBeans is uncomfortably large for that. I had to reduce the font size a bit to cope. Thanks for all the other tips. I’ve been checking them out as you’ve been providing them.

  45. Tor Norbye

    Just a couple of more tips if you try NetBeans in the future, regarding your window screen size Shift-Escape will maximize the editor window (or whatever window has focus) – Shift-Escape again to toggle back. You can also run the IDE in fullscreen mode (no space for window decorations).

    There’s also some refactoring operations such as find usages and rename, assign expression to var, etc.

  46. Alain M. Lafon

    @Tor @Shannon
    I just tried your latest stable build of NB 6.7
    I made my standard test: a new project, one variable holding some string content which I want to print. The debugger seemed to work, didn’t crash instantly this time. But when I wanted to change the content of the variable dynamically, Netbeans crashed on me again.
    But I have to say, I like the new looks – and whenever you add a couple more features other than “rename” to the Refactoring menu, I will certainly try it again.
    Anyway, as of now – three out of three fails when trying to debug a two line program; can’t use that in production as of now..
    @Tor Thank you for you shortcuts, I will try them in my current NB stable version for Ror and Java.

  47. Alain M. Lafon

    @Shannon
    I just compiled a custom MacVim to include support for Python 2.5
    * Clone the MacVim.git repo: git clone git://repo.or.cz/MacVim.git vim7
    * Configure and build Vim: cd vim7/src; ./configure –enable-gui=macvim –enable-pythoninterp; make
    * Build MacVim.app: cd MacVim; xcodebuild
    * Run: open build/Release/MacVim.app
    Most of this is taken from the MacVim site.
    PyFlakes will work with it, but not too smooth – I have to keep refreshing PyFlakes myself. It’s a first step, though. Besides having Python 2.5 will probably prove useful in other ways, too.

  48. KarasAya

    Nice article, especially the introduce of OmniComplete for python and VimPDB!
    Maybe you can check my project exVim:

    http://code.google.com/p/exvim/

    I used to use it to develop python.

  49. Peter

    A good alternative graphical degubber is winpdb – I also added a little section on embedded debugging a year or two ago using vim scripts as an example. winpdb is so useful if you want to extend vim.

  50. frt's status on Tuesday, 30-Jun-09 20:07:45 UTC - Identi.ca

    […] #4tw! http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ […]

  51. amandinhakee's status on Tuesday, 30-Jun-09 20:48:02 UTC - Identi.ca

    […] @frt #vim #4tw! http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ !vim | I <3 vim […]

  52. Nilson

    Good job, i really liked it.

  53. Anderson Santos

    A colleague mapped the buffer next, buffer previous to work with ctrl+tab, not sure if minbuftab does the same, but I find it very neat and just requires to write on .vimrc file

    ” Buffer navigation (Ctrl+Tab / Ctrl+Shift+Tab)
    nnoremap :bnext
    nnoremap :bprevious

  54. Anderson Santos

    ops, it was considered html

    ” Buffer navigation (Ctrl+Tab / Ctrl+Shift+Tab)
    nnoremap <C-Tab> :bnext<CR>
    nnoremap <C-S-Tab> :bprevious<CR>

  55. Dayo (jargon) 's status on Saturday, 07-Nov-09 10:05:40 UTC - Identi.ca

    […] http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ a few seconds ago from web in context […]

  56. links for 2009-06-03 | blog/shl@INTERDOSE

    […] VIM as Python IDE | Alain M. Lafon (tags: vim python) […]

  57. Peter

    I found this tutorial useful and few months ago and came across it again a couple of days ago and it has such useful information on configuring vim/python I wanted to share a little idiom I’ve found useful for years in setting up vim for different jobs.

    For example, for exiting xml I like to use only 2 spaces for tabs as the nesting for xml tends to be deep. Python on the other hand has a coding standard, so I like to try to stick to to (not positive my config is currently correct in this regards but it’s close).

    The auto file detection is best left down to vim if you can but in the following I’ll show how I use my own detection if necessary:

    function! FixMurphy()
    if g:colors_name == ‘murphy’
    hi Folded guibg=Black
    endif
    endfunction

    function! SetXMLFile()
    set tw=100
    set sw=2
    set ts=2
    “set guioptions+=m
    set foldmethod=marker
    call FixMurphy()
    digraphs RE 8477 fc 402 bb 8226
    ” ℝ – set of real numbers
    ” ƒ – function
    endfunction

    function! SetPythonFile()
    set omnifunc=pythoncomplete#Complete

    “tasklist
    map ttl :TaskList
    “taglist
    map ttt :TlistToggle
    let g:Tlist_GainFocus_On_ToggleOpen = 1
    let g:Tlist_Auto_Update = 1
    let g:Tlist_Compact_Format = 1

    set expandtab
    set textwidth=72
    set tabstop=4
    set softtabstop=4
    set shiftwidth=4
    set autoindent
    endfunction

    function! SetMakoFile()
    set tw=100
    set sw=2
    set ts=2
    endfunction

    autocmd FileType xml,xslt,html,xhtml,xsd call SetXMLFile()
    autocmd FileType python call SetPythonFile()
    autocmd FileType mako call SetMakoFile()
    autocmd FileType java call SetJavaFile()

    autocmd BufRead,BufNew,BufNewFile *.xsd,*.zcml,*.pt,*.kid set filetype=xml
    autocmd BufRead,BufNew,BufNewFile *.mak set filetype=mako

    I’ve seen quite a bit on this subject but this is what I do. Its flexible, uses vim where possible to detect file types and applys configuration changes dependent on what I’m working on.

  58. Setting up VIM as a Python IDE « KcodeL

    […] leave a comment » http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ […]

  59. Anton

    Can you make, PACK with your VIM or show you vimrc
    PLEASE

  60. rxwen

    Great stuff. thanks

  61. anarch's me2DAY

    맹수의 느낌…

    VIM as Python IDE | Alain M. Lafon…

  62. thrope

    This script makes a nice addition:
    http://www.vim.org/scripts/script.php?script_id=891

    Checks with pylint on every buffer write (optional) and displays errors in vim quickfix.

    ..

  63. VIM as Python IDE | Alain M. Lafon « BenGeek blog

    […] as Python IDE | Alain M. Lafon Filed under: Uncategorized — djpool @ 11:17 VIM as Python IDE | Alain M. Lafon. Laisser un […]

  64. le

    can you publish your .vimrc and vimfiles,but I can’t as you like and I like it.
    please send to me ,thanks !

  65. Sinkro.net · links for 2010-09-24

    […] VIM as Python IDE | Alain M. Lafon (tags: python vim vi editor configuration) […]

  66. Twitted by jvalleroy

    […] This post was Twitted by jvalleroy […]

  67. python problem

    […] out how I can use vim as python editor. I installed gvim and did all the steps from this page : VIM as Python IDE | Alain M. Lafon But still no luck. Roelof Reply With Quote + Reply to […]

  68. python - vim problem

    […] – vim problem Hello, I installed vim and the plugins according to this page : VIM as Python IDE | Alain M. Lafon But nothing has changed. What went wrong ? Roelof Reply With Quote + […]

  69. Sandys Pizza Menu

    Very informative. Are you going to post more on this?

  70. IDE for python « Yet Another Developers' Blog

    […] vim […]

  71. [Fwd:]Vim as Python IDE on windows | 活着"只"为改变世界

    […] VIM as Python IDE […]

  72. Weldon Groch

    Julianne Hough, known as much for her Dancing With the Stars gig as for her country music, is achieving new popularity by combining both

  73. luo

    hi Alain. I got a problem with taglist. The official document of taglist says: press on file name tags to display the full path to the file. It works for me sometimes, sometimes it does not work or it works in one directory but does not work in another.It just show the file name not the full path.

  74. yaami

    Hi Alan, Great article. I’ve been looking for python autocomplete feature. Found here. Thanks.

    BTW what is the color scheme you are using looks good.

  75. Alain M. Lafon

    Hi yaami,

    great to hear that my blog was of value to you. The colorscheme used is “wombat”. You might also want to check out “zenburn”.

    Best,
    Alain

  76. Online Auctions Not Ebay

    I am going to strart an on line vendue website like ebay. Does anyone know where I can ascertain good auction software package. Most of the damages I have found out for software package has been $1000.00 and up. I would like to find a less expensive software system if possible.

  77. Valter Foresto

    GREAT INFOS FOR PYTHONISTS, THANKS A LOT !

  78. Meu ambiente de trabalho em 7 itens | rochacbruno

    […] 4. VI/VIM […]

  79. [Fwd:]Vim as Python IDE on windows – All is well.

    […] VIM as Python IDE […]

  80. IDE for Python with VIM « KAIGARA Online

    […] http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ […]

  81. Phil

    Hi! Thanks for the nice article!
    I am new to Python and I’m trying to figure out which editor/IDE to use. I tried WingIDE, and find it very nice (but still runs in XQuartz/X11 on Mac OSX). I have been checking out quite a few others too.

    TextMate seems nice, as it has command completion, but it does not have Call Type hints. It does however help to type a lot. Like if I type class and press tab, it fills out lots of stuff …

    But vi(m) is a nice friend, and quick, so I decided to give your setup a try. I got it installed and working (I think), haven’t seen error messages upon startup. Now I am trying to figure out what MacVim with this setup does.

    Vim’s Omni Completion seems to have call type (lookup of functions, C-x C-o), but I don’t seem to get completion of commands, like print(), str(), list() and so on. Is that correct? Or am I missing something vital?

    VimPdb seems to work nice, and I can step through the program(s), but (and this might be a n00b question) how do I just run the entire program in a separate buffer/window/tab?

    If one wanted automated stuff like TextMate offer, text macros could help, but still there’s no way to make them as interactive as in TM? (Adding new defs as you add to the class and so on.)


    Phil 8)

  82. Alain M. Lafon

    Hi there,

    if you want to save more typing with automated macros like in TM, you could take a look at the SnipMate plugin.

    Best,
    Alain

  83. Kasha Peffly

    This is very attention-grabbing, You’re an overly professional blogger. I have joined your feed and sit up for in the hunt for extra of your excellent post. Additionally, I’ve shared your web site in my social networks!

  84. Links for 2011-05-29 at The Standard Output

    […] Pycon! How this site was created Brushing up on Computer Science Part 1, Big O » Victus Spiritus VIM as Python IDE | Alain M. Lafon Python and vim: Make your own IDE | tail -f […]

  85. Aniket Deshpande

    I have recently started using vim, and programming in python. I like vim. I have a Macbook with OS X 10.6.8. I ran through your instructions till i hit a dead-end at ‘installing ctags’. At ‘./configure && sudo make install’ CONFIGURE is not part of the package I downloaded: the ctags58.zip from sourceforge.

    As you might have guessed by my question, Im totally lost and dont know how to approach, or where to look for the solution to this problem. I do not know the directory structures of this particular mutant of UNIX, or which files do what, and do not know much of C except very very little and have no experience with tools like make.

    Help me out. A mail, if possible, with detailed instructions would be something that… I will not find words to thank you with.

    utmost regards

  86. Alain M. Lafon

    Hi Aniket,

    thank you for your interest in the article. I can help you out.

    What is missing is a build system for C programs on your machine.
    The easiest way to get that in Mac OSX is to install XCode[1]
    from Apple.

    Best to you and have fun using VIM,
    Alain

    1. http://developer.apple.com/technologies/tools/

  87. Programando em Python no Vim | Pythonize

    […] interessantes que podem ser adicionadas ao Vim para codificação Python podem ser vistas em: VIM as Python IDE. […]

  88. Hell-G

    Hi Alain

    Thank you very much for this article! It helped me alot.
    I have one question, you mention “even the whole Pydoc gets to be displayed in a split window”. How did you manage to get this to work with omni completion? I can use omni completion alone fine and I get the Pydoc for the word under the cursor by hitting “K”, but how did you combine them?

    Thanks for your help!

    Regards,
    Hell-G

  89. Which is the better Python IDE, Komodo IDE, PyCharm, WingIDE or something else and why? - Quora

    […] to customize for python dev.Here are a few link which may help you:http://wiki.python.org/moin/Vimhttp://blog.dispatched.ch/2009/0…In my case, it took quite some time to put my .vimrc in shape for proper development.You should also […]

  90. Sean E

    I had to add the following lines to my .vimrc for omnicompletion to work:

    filetype plugin on
    set ofu=sytaxcomplete#Complete

  91. Jose

    Well done, man. Very useful tips and plugins and quite clear explained. Thank you!

  92. klen

    Hello!

    See my plugin for vim: https://github.com/klen/python-mode

    Screencast here: http://t.co/3b0bzeXA

  93. VIM as a Python IDE. « Talueee's Blog

    […] Link Like this:LikeBe the first to like this post. […]

  94. ToughGuy

    nice post. that’s all i wanna say.

    非常好的帖子~谢谢了。

    Thank You!

  95. Omni completion « Åke i exil

    […] att ha läst ett intressant bloginlägg om att använda vim som Python-IDE har även jag konfigurerat upp vim att åtminstone låta mig […]

  96. uggs

    Fantastic web site. A lot of useful info here. I’m sending it to some pals ans also sharing in delicious. And certainly, thank you for your sweat!

  97. nullled script

    Simply want to say your article is as astounding. The clarity in your post is simply spectacular and i could suppose you’re a professional in this subject. Well together with your permission allow me to take hold of your RSS feed to stay updated with forthcoming post. Thanks one million and please carry on the enjoyable work.

  98. Customising OSX « Life is a State of Mind

    […] with python support. Any thoughts as to how I can do this? I have followed advice so far from these really good sources for this […]

  99. tshirtman

    I want to point out, because i looked for this for a very long time, but i finally found a decent python completion/refactoring plugin for vim, none of the ones i tried before worked except for very simple cases, but this one seems to work way more reliably:

    https://github.com/klen/python-mode

    installed with pathogen, work like a charm… at least…

  100. Tom

    Hey there,
    great work with the tutorial.
    I got everything working, even autocompletion works (better with the following: http://vim.wikia.com/wiki/VimTip1386 )
    BUT:
    I just cannot run the script. By pressing F5 it gets me into the strangest Python files. For example it opens __init__.py utf_8.py and codecs.py.
    By executing it with IDLE it works just fine…

    (I am running Windows and gVim7.3 and Python 2.7)

    @tshirtman
    I tried the python-mode as well, but in which folder is it to put?
    just vim/bundle/python-mode
    and then it is already loaded with the default _vimrc settings?

  101. aprendendo VIM @ Linux 2 Start

    […] Porque é divertido aprender! Veja por exemplo : VIM as Python IDE. […]

  102. Made the switch to Vim – at last! | vimalkumar.in

    […] vimrc Turning Vim into a modern Python IDE VIM as Python IDE Vim made easy: how to get your favorite IDE features in Vim Right margin in Vim Solarized color […]

  103. Vim: tips and tricks » cloud101

    […] VIM as Python IDE  Tagged with: linux, tips, tricks, vim, vimrc […]

  104. sponsor child

    Hello there, simply changed into alert to your blog thru Google, and located that it is truly informative. I am going to be careful for brussels. I will be grateful if you happen to proceed this in future. Many folks might be benefited out of your writing. Cheers!

  105. Corey Richardson

    For those looking to manage ‘packages’ in Vim: Vundle! (https://github.com/gmarik/vundle)

  106. Adam

    you might want to add this for future windows users who come here:

    when you say: let Tlist_Ctags_Cmd=’/usr/local/bin/ctags’

    windows needs: let $Tlist_Ctags_Cmd=’/usr/local/bin/ctags’

    The “$” needs to be added for this line to work correctly in windows. Otherwise you will get an error generating tags message.

  107. Adam

    Great tutorial by the way. I do have a question though. How do I set up omni completion for wxpython functions?

  108. Alain M. Lafon

    As far as I remember this was not the case when I set it up. But it has been a couple of years since then. Plus I was on XP(;

    Thank you for your insight!

  109. Editors for Programmers « Style is the dress of thought; Shame is Pride's cloak

    […] VIM as Python IDE | Alain M. […]

  110. 【转】 Python 二三事 | 流水年华

    […] Vim as Python IDE 只要搜 Python 和 Vim 就一定会找到这一篇文章。 […]

  111. free.fr

    Admiring the hard work you put into your

    website and detailed information you present. It’s nice to come

    across a blog every once in a while that isn’t the same old rehashed

    information. Fantastic read! I’ve saved your site and I’m including your

    RSS feeds to my Google account.

  112. Vim as Python IDE on windows - The Art of Virtualization

    […] VIM as Python IDE […]

  113. Vim相关资料大全 | 天天三国杀

    […] Vim as Python IDE […]

  114. What is the best text editor to use with python | Resume Rewriter Free

    […] to use with python: http://dancingpenguinsoflight.com/2009/02/python-and-vim-make-your-own-ide/ http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ http://sublimetext.com/ http://pydev.org/ http://www.jetbrains.com/pycharm/ http://setup.py/ […]

  115. orquestas de madrid

    I really like what you guys are up too. This kind of cleger work and exposure!

    Keep upp the wondetful works guys I’ve incorporated you guys
    to blogroll.

  116. mfukar

    Hell-G,

    if you want the Python docstrings to be displayed with omnicompletion, make sure you add ‘preview’ to ‘completeopt':

    set completeopt+=preview

  117. Python and Intellisense - Zwagerman Gyan

    […] This blog opening explains sourroundings Vim adult as a Python IDE, he covers Intellisense-like functionality: […]

  118. Https://TedDzDViDI.Jux.Com

    WOW just what I was looking for. Came here by searching for coding

  119. Python and Intellisense | Zenor

    […] This blog opening explains sourroundings Vim adult as a Python IDE, he covers Intellisense-like functionality: […]

  120. Fix Vim Taglist Error Windows XP, Vista, 7, 8 [Solved]

    […] VIM as Python IDE – Munen Alain M. Lafon Blog – mark May 24th, 2009 at 12:06 pm. Thanks, in particular for taglist, that’ll make things easier. Technically your settings for PEP8 conformance are incorrect …… […]

  121. Searching for a Python lightweight IDE (or text-editor) [duplicate] | Ngoding

    […] Cruder look, but very lightweight and extremely powerful: you could look at using Vim as a Python IDE. […]


Leave a Reply


*