background preloader


Facebook Twitter

Vim as a Python IDE - Martin Brochhaus. Vim as a Python IDE - Martin Brochhaus. Klen/python-mode. Davidhalter/jedi-vim. Davidhalter/jedi. Vim as a Python IDE. Ropevim, rope in vim. John Anderson ( sontek ) - Turning Vim into a modern Python IDE. $ git clone $ cd dotfiles $ .

John Anderson ( sontek ) - Turning Vim into a modern Python IDE

/ vim Download PDF Version Back in 2008, I wrote the article Python with a modular IDE (Vim). Years later, I have people e-mailing me and commenting daily asking for more information, even though most of the information in it is outdated. Here is the modern way to work with Python and Vim to achieve the perfect environment. Because one of the most important parts about a development environment is the ability to easily reproduce across machines, we are going to store our vim configuration in git: $ mkdir ~/.vim/ $ mkdir ~/.vim/{autoload,bundle} $ cd ~/.vim/ $ git init The purpose of the autoload directory is to automatically load the vim plugin Pathogen, which we'll then use to load all other plugins that are located in the bundle directory.

You'll need to add the following to your ~/.vimrc so that pathogen will be loaded properly. Filetype off call pathogen#runtime_append_all_bundles() call pathogen#helptags() Thats it! Code Folding Window Splits Pep8. Indenting Python with VIM. Vim’s default configuration for Python sucks!

Indenting Python with VIM

If you have used Vim to write Python code, you probably know this very well. It does not align to parentheses and braces. dict(foo=bar<return> _ <= directly insert a 'tab' {'hello': 'world',<return> _ <= Same thing! It doesn’t add indentation after Python keyword if True:<return> _ <= Come on! Not even mentioning insanities like: insert tabs instead of spaces, or tab width is 8 spaces. Making Vim PEP-8 friendly Sane defaults First I would like to point out something when writing a Vim configuration file. Generally don’t use the autocmd command to add hooks to a specific filename’s extension.

Autocmd FileType python is better. AutoCmd BufNewFile,BufRead *.py \ setlocal tabstop=4 \ setlocal softtabstop=4 \ setlocal shiftwidth=4 \ setlocal textwidth=80 \ setlocal smarttab \ setlocal expandtab Create the directory ~/.vim/ftplugin; create a file named ~/.vim/ftplugin/python.vim containing: Sexy edition Now let’s tackle the edition problem.

VIM as Python IDE. Finding the perfect IDE for Python isn’t an easy feat.

VIM as Python IDE

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. From the eye-candy to the implementation. . to vimrc. Vim home page.