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:
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.
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).
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.
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.
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.
–
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 |
Category: articles | Tags: coding, ctags, exuberant ctags, ide, minibuf, omni completion, pep 8, programming, python, python ide, taglist, tasklist, tutorial, vi, vim, vimpdb, walkthrough 98 comments »






May 24th, 2009 at 6:39 am
[...] VIM as Python IDE | Alain M. Lafon [...]
May 24th, 2009 at 6:54 am
popurls.com // popular today…
story has entered the popular today section on popurls.com…
May 24th, 2009 at 9:34 am
[...] This post was Twitted by preek – Real-url.org [...]
May 24th, 2009 at 10:06 am
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
May 24th, 2009 at 12:01 pm
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
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, 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.
May 24th, 2009 at 2:09 pm
I’m so glad I don’t code in a language that requires soft-tabs
May 24th, 2009 at 2:21 pm
@Mark.
You’re absolutely right – I have corrected it right away. Thanks for the advice.
May 24th, 2009 at 2:22 pm
@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.”
May 24th, 2009 at 7:25 pm
[...] VIM as Python IDE | Alain M. Lafon [...]
May 24th, 2009 at 7:50 pm
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
May 25th, 2009 at 2:56 am
[...] VIM as Python IDE | Alain M. Lafon (tags: python Vim programming IDE tips howto) [...]
May 25th, 2009 at 7:00 am
God, that image zoom script is SLOW!
May 25th, 2009 at 7:41 am
@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.
May 25th, 2009 at 8:26 am
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
May 25th, 2009 at 10:24 am
[...] 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) [...]
May 25th, 2009 at 12:02 pm
@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(;
May 25th, 2009 at 7:05 pm
[...] Via | Dispatched [...]
May 25th, 2009 at 9:55 pm
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! :)
May 25th, 2009 at 10:24 pm
> 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
May 26th, 2009 at 4:52 am
> 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.
May 26th, 2009 at 7:00 am
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-tabfeature 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.May 26th, 2009 at 7:14 am
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^^).
May 26th, 2009 at 7:28 am
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,
May 26th, 2009 at 7:29 am
/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
May 26th, 2009 at 7:29 am
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.
May 26th, 2009 at 7:30 am
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
May 26th, 2009 at 7:34 am
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.
May 26th, 2009 at 7:34 am
Similar setup for PHP: http://gravitonic.com/files/talks/php-quebec-2009/vim-for-php-programmers.pdf
May 26th, 2009 at 7:35 am
grr, formatting.
http://ed.cranford.googlepages.com/vimrc if you’re really interested in seeing my vimrc. I’m not fond of plugins.
May 27th, 2009 at 6:46 am
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
May 27th, 2009 at 9:07 am
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.
May 27th, 2009 at 9:24 am
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?
May 27th, 2009 at 12:01 pm
[...] | > `
May 27th, 2009 at 11:35 pm
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
May 28th, 2009 at 12:33 am
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.
May 28th, 2009 at 4:44 am
[...] Here is a nice article about using VIM as a Python IDE. [...]
May 28th, 2009 at 4:57 pm
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
May 28th, 2009 at 9:14 pm
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(;
May 30th, 2009 at 1:12 pm
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).
May 30th, 2009 at 1:14 pm
@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.
May 30th, 2009 at 1:16 pm
@Shannon
Thanks for your additional configuration.
Thinking of autocomplete; my opinion is that not much beats VIM with the SuperTab plugin, though.
May 30th, 2009 at 1:23 pm
@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.
May 30th, 2009 at 10:16 pm
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.
May 31st, 2009 at 6:00 pm
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.
June 25th, 2009 at 11:15 pm
@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.
June 25th, 2009 at 11:16 pm
@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.
June 25th, 2009 at 11:18 pm
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.
June 25th, 2009 at 11:18 pm
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.
June 30th, 2009 at 9:07 pm
[...] #4tw! http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ [...]
June 30th, 2009 at 9:48 pm
[...] @frt #vim #4tw! http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ !vim | I <3 vim [...]
July 1st, 2009 at 1:06 pm
Good job, i really liked it.
August 6th, 2009 at 6:40 pm
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
August 6th, 2009 at 6:42 pm
ops, it was considered html
” Buffer navigation (Ctrl+Tab / Ctrl+Shift+Tab)
nnoremap <C-Tab> :bnext<CR>
nnoremap <C-S-Tab> :bprevious<CR>
November 7th, 2009 at 11:05 am
[...] http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ a few seconds ago from web in context [...]
December 22nd, 2009 at 12:58 pm
[...] VIM as Python IDE | Alain M. Lafon (tags: vim python) [...]
January 23rd, 2010 at 6:49 pm
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.
January 31st, 2010 at 3:43 pm
[...] leave a comment » http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ [...]
February 26th, 2010 at 6:21 am
Can you make, PACK with your VIM or show you vimrc
PLEASE
June 3rd, 2010 at 3:47 pm
Great stuff. thanks
July 8th, 2010 at 12:41 pm
맹수의 느낌…
VIM as Python IDE | Alain M. Lafon…
August 13th, 2010 at 11:47 am
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.
..
August 13th, 2010 at 12:17 pm
[...] as Python IDE | Alain M. Lafon Filed under: Uncategorized — djpool @ 11:17 VIM as Python IDE | Alain M. Lafon. Laisser un [...]
August 31st, 2010 at 7:11 pm
can you publish your .vimrc and vimfiles,but I can’t as you like and I like it.
please send to me ,thanks !
September 24th, 2010 at 8:03 pm
[...] VIM as Python IDE | Alain M. Lafon (tags: python vim vi editor configuration) [...]
October 6th, 2010 at 12:51 am
[...] This post was Twitted by jvalleroy [...]
October 19th, 2010 at 5:05 pm
[...] 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 [...]
October 19th, 2010 at 7:41 pm
[...] – 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 + [...]
October 21st, 2010 at 6:01 pm
Very informative. Are you going to post more on this?
October 27th, 2010 at 4:36 am
[...] vim [...]
November 30th, 2010 at 5:22 pm
[...] VIM as Python IDE [...]
December 19th, 2010 at 7:53 pm
Julianne Hough, known as much for her Dancing With the Stars gig as for her country music, is achieving new popularity by combining both
December 23rd, 2010 at 9:04 am
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.
January 9th, 2011 at 8:21 am
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.
January 9th, 2011 at 11:21 am
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
January 10th, 2011 at 4:35 am
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.
February 17th, 2011 at 5:46 pm
GREAT INFOS FOR PYTHONISTS, THANKS A LOT !
February 21st, 2011 at 6:19 pm
[...] 4. VI/VIM [...]
March 1st, 2011 at 8:54 am
[...] VIM as Python IDE [...]
March 25th, 2011 at 1:40 pm
[...] http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/ [...]
April 18th, 2011 at 11:20 pm
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)
May 7th, 2011 at 4:23 pm
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
May 9th, 2011 at 5:10 pm
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!
May 30th, 2011 at 4:54 am
[...] 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 [...]
August 27th, 2011 at 10:46 pm
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
August 28th, 2011 at 8:12 pm
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/
September 8th, 2011 at 3:45 pm
[...] interessantes que podem ser adicionadas ao Vim para codificação Python podem ser vistas em: VIM as Python IDE. [...]
September 9th, 2011 at 3:44 pm
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
September 10th, 2011 at 5:41 am
[...] 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 [...]
September 14th, 2011 at 7:29 pm
I had to add the following lines to my .vimrc for omnicompletion to work:
filetype plugin on
set ofu=sytaxcomplete#Complete
September 20th, 2011 at 7:00 pm
Well done, man. Very useful tips and plugins and quite clear explained. Thank you!
October 11th, 2011 at 6:56 pm
Hello!
See my plugin for vim: https://github.com/klen/python-mode
Screencast here: http://t.co/3b0bzeXA
November 29th, 2011 at 1:53 am
[...] Link Like this:LikeBe the first to like this post. [...]
December 2nd, 2011 at 4:40 pm
nice post. that’s all i wanna say.
非常好的帖子~谢谢了。
Thank You!
December 6th, 2011 at 9:46 pm
[...] 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 [...]
December 10th, 2011 at 1:10 am
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!
January 5th, 2012 at 11:59 am
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.
January 15th, 2012 at 1:46 pm
[...] 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 [...]