<img height="1" width="1" style="display:none" src="https://www.facebook.com/tr?id=338168267432629&amp;ev=PageView&amp;noscript=1">
Programming

Setting Up and Using Vim for Python / Django Development

There are a lot of text editors and IDEs for a popular language such as Python, and we’ve already featured Eclipse/PyDev before. Today, we’ll focus on Vim, a highly configurable text editor built to enable efficient text editing. From the Vim website: Vim is often called a “programmer’s editor,” and …


There are a lot of text editors and IDEs for a popular language such as Python, and we’ve already featured Eclipse/PyDev before. Today, we’ll focus on Vim, a highly configurable text editor built to enable efficient text editing. From the Vim website:

Vim is often called a “programmer’s editor,” and so useful for programming that many consider it an entire IDE. It’s not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.

We’ll go through the installation and Python/Django-specific configuration through different levels, and depending on where you stop, you’ll get either a simple text editor, a full-blown IDE, or something in between.

Easy Level: Installation

Assuming you are using Ubuntu: sudo apt-get install vim

For other operating systems: http://www.vim.org/download.php

Once you’re done, running vim with a file will show something like this:

tumblr_m6aw4qNVQe1qcbckf

Normal Level: Basic Config

Most of our configuration will happen in your vimrc file. Check the wiki entry for this.

The basics would be:

syntax on "syntax 
filetype on "filetype detection 
filetype plugin indent on "filetype-based indentation 
set tabstop=4 expandtab shiftwidth=4 softtabstop=4 "python-compatible tab setup 
set foldmethod=indent foldlevel=99 "python-compatible folding
set number "line numbers

The result of that config will look like this:

tumblr_m6aw7pAhIR1qcbckf

Interlude:

The wonder of vim is that from here on, you’re best left on your own to try out the different modes, configurations and plugins that will match your workflow. And the corollary wonder is that whenever you see a tip about vim, you’re learning something new. To point you to some resources:

Hard Level: Advanced Config

If you’re looking for Here are some links to existing guides for using Vim as a Python/Django IDE, in order of Django-specificness:

Going through this will result in an IDE-like environment as shown in the image in the Vim as Python IDE post:

vim-as-python-ide

Similar posts

Get notified about the latest in Tech

Be the first to know about new tech from the experts at Bixly!