Python-Mode – A Simple Vim Python Plugin

So I am fairly new to Python –I’ve been using it since August, 2011– and I must confess, its nothing less than amazing. Its amazing what a few lines of Python code are capable of doing; and if for some reason you do not believe what I am saying, perhaps this [1] might convience you otherwise. When I initially started using Python, Vim [2] proved sufficient.

Things are not always straight forward though 🙁 I reached a stage where I was increasingly requiring features that the default Vim editor settings could not offer –code completion, reliable debugging features, code refactoring… In a nutshell, the default Vim settings were more than sufficient for basic scripting, but I guess I just needed more.

I spent the last two days evaluating the slew [3, 4, 5] of Python IDEs/editors and initially settled for the PyDev Eclipse plugin. Its actually interesting to note that the Python IDEs/editors war [6, 7] has been going on for quite some time now 😉 Anyway, I actually ended up using PyDev for a couple of hours yesterday before I finally settled for Python-Mode [8] –a Vim Python pluglin. The reason behind my choice is simple –its the simplicity of the plugin and the power that comes with Vim editor. I am not very convesant with Vim itself and had issues setting up the plugin; you might want to check out the conversation I had with the guys maintaining the plugin code [9] prior to turning my Vim editor into a Python IDE 😀

In case you decide to use the plugin, below are a few simple steps you will have to follow;

Clone the remote Git repository and create a local copy of the repository

phiri@phrlig001:~$ git clone https://github.com/klen/python-mode.git

Copy plugin directories and files to ~/.vim directory

phiri@phrlig001:~$ cd python-mode
phiri@phrlig001:~$ rsync -ar * ~/.vim

Open ~/.vimrc file and append the code below to activate plugin

filetype plugin indent on

The result is below

A Simple Vim Python Plugin

A Simple Vim Python Plugin

Good luck turning your Vim into a morden Python IDE/editor.

References

[1] http://twiki.cern.ch/twiki/bin/view/CDS/PythonAdvocacy 
[2] http://www.vim.org/
[3] http://sontek.net/turning-vim-into-a-modern-python-ide
[4] http://blog.dispatched.ch/2009/05/24/vim-as-python-ide/
[5] http://wiki.python.org/moin/IntegratedDevelopmentEnvironments
[6] http://stackoverflow.com/questions/81584/what-ide-to-use-for-python
[7] http://regebro.wordpress.com/2010/10/09/is-there-a-better-python-ide/
[8] https://github.com/klen/python-mode
[9] https://github.com/klen/python-mode/issues/18

Categories: Technical
Tags: , , ,