Vim (source code), short for Vi IMproved, is a configurable text editor often used as a Python development environment. Vim proponents commonly cite the numerous plugins, Vimscript and logical command language as major Vim strengths.

Why is Vim a good Python development environment?

Vim's philosophy is that developers are more productive when they avoid taking their hands off the keyboard. Code should flow naturally from the developer's thoughts through the keyboard and onto the screen. Using a mouse or other peripheral is a detriment to the rate at which a developer's thoughts become code. This "efficiency by keyboard" keeps Vim as one of the most popular text editors despite having been around for decades. Few programming tools have that kind of staying power.

Vim has a logical, structured command language. When a beginner is learning the editor she may feel like it is impossible to understand all the key commands. However, the commands stack together in a logical way so that over time the editor becomes predictable.

Configuring Vim with a Vimrc file

The Vimrc file is used to configure the Vim editor. A Vimrc file can range from nothing in it to very complicated with hundreds or thousands of lines of configuration commands.

Here's a short, commented example .vimrc file I use for Python development to get a feel for some of the configuration statements:

" enable syntax highlighting syntax enable " show line numbers set number " set tabs to have 4 spaces set ts=4 " indent when moving to the next line while writing code set autoindent " expand tabs into spaces set expandtab " when using the >> or << commands, shift lines by 4 spaces set shiftwidth=4 " show a visual line under the cursor's current line set cursorline " show the matching part of the pair for [] {} and () set showmatch " enable all Python syntax highlighting features let python_highlight_all = 1

Here is how these configuration options look with a dark background on Mac OS X while editing the markdown for this webpage (how meta!).

Take a look at another example using these configuration options, this time with a light background and editing Python code from my Choose Your Own Adventures Presentations project.

The Vimrc file lives under the home directory of the user account running Vim. For example, when my user account is 'matt', on Mac OS X my Vimrc file is found at /Users/matt/.vimrc . On Ubuntu Linux my .vimrc file can be found within the /home/matt/ directory.

If a Vimrc file does not already exist, just create it within the user's home directory and it will be picked up by Vim the next time you open the editor.

Vim tutorials

Vim has a reputation for a difficult learning curve, but it's much easier to get started with these tutorials.

Vimrc resources

These are a few resources for learning how to structure a .vimrc file. I recommend adding configuration options one at a time to test them individually instead of going whole hog with a Vimrc you are unfamiliar with.

Vim installation guides

These installation guides will help you get Vim up and running on Mac OS X, Linux and Windows.

Upgrading Vim on OS X explains why to upgrade from Vim 7.2 to 7.3+ and how to do it using Homebrew.

The easiest way to install Vim on Windows 7+ is to download and run the gvim74.exe file.

On Linux make sure to install the vim package with sudo apt-get install vim .

If you're using PyCharm as your IDE you won't need to install Vim as a separate text editor - instead use the IdeaVim PyCharm plugin to get Vim keybindings, visual/insert mode, configuration with ~/.ideavimrc and other Vim emulation features.

Using Vim as a Python IDE

Once you get comfortable with Vim as an editor, there are several configuration options and plugins you can use to enhance your Python productivity. These are the resources and tutorials to read when you're ready to take that step.

Vim Plugin resources

Vim Plugin Managers

If you use many Vim plugins together it is really handy to have a plugin managers to sort out all of the dependencies. The following plugin managers are the most commonly-used ones in the Vim ecosystem.

Vundle comes highly recommended as a plugin manager for Vim.

Pathogen is a widely used plugin manager.

Vim-plug bills itself as a minimalistic Vim plugin manager.

Niche tutorials

After you have been using Vim for awhile there will be features you bump into without realizing they were ever there. The following tutorials show how to use some specific niche features. You may already know about these if you have been using Vim for awhile but everyone's learning path is different so it's useful to do a quick scan to make sure you are not missing anything.

Vim’s absolute, relative and hybrid line numbers shows how to change the line numbering scheme. There was a period of time I used relative line numbers although I eventually switched back to absolute numbers. The usefulness of these schemes is often dependent on what language you are working in.

A simpler Vim statusline explains how to customize your bottom screen statusline without using plugins such as vim-powerline or vim-airline.

The vim-clutch is a really cool project and walkthrough that shows how you can create a foot pedal to switch between Normal and Insert modes instead of using the typical ESC key (or a remapped key).

How I'm able to take notes in mathematics lectures using LaTeX and Vim explains how the author is able to keep up with mathematics lectures by using Vim and LaTeX which produces gorgeous notes that can be used to study.

Now that you know about Vim, what do you want to develop in it?