Thursday, January 31, 2013

Vim for Python Development

Testing a PyOpenCL demo in vim.

This is my collection of hacks that turn vim into a python IDE.

Syntax Highlighting


I'm using Arch Linux and Syntax Highlighting comes installed with my Vim package. I just need to enable the syntax highlighting in my .vimrc file:

Enable line numbers


Is as simple as adding this line to the .vimrc

Indentation


Adding this to the .vimrc file will enable PEP8 indentation only for *.py files.

Autocompletion


I use the great jedi-vim plugin from David Halter and the SuperTab plugin. You can find the installation steps at RedKrieg's post: Writing Python like a Jedi.

Testing the jedi-vim plugin

Executing python code inside vim


This is my favorite, press the F5 key to save the python script and execute it. Add this to the .vimrc file.

Enable file specific features


To enable all the filetype features I've defined above the following lines are needed in the .vimrc file.

Other plugins


Here is a collection of other useful plugins, I recommend installing them using pathogen if you can't get them from the repositories of your Linux distro.


If you have hacks of your own, please share them with everyone in the comments section.

No comments:

Post a Comment