Vim and Python: The Unbreakable Match

If you write your python codes in vim editor all the time, you should checkout the python-mode vim plugin that comes with features that will make you feel as if you are using an IDE for Python:

  • Syntax highlighting
  • Virtualenv support
  • Run python code (`r`)
  • Add/remove breakpoints (`b`)
  • Improved Python indentation
  • Python folding
  • Python motions and operators (`]]`, `3[[`, `]]M`, `vaC`, `viM`,`daC`, `ciM`, …)
  • Code checking (pylint_, pyflakes_, pylama_, …) that can be runsimultaneously (`:PymodeLint`)
  • Autofix PEP8 errors (`:PymodeLintAuto`)
  • Search in python documentation (`K`)
  • Code refactoring (rope_)
  • Strong code completion (rope_)
  • Go to definition (`g` for :RopeGotoDefinition)

It is recommended that you install python-mode with Pathogen which is another Vundle like plugin manager for vim. To install Pathogen, run the following command from your terminal:


mkdir -p ~/.vim/autoload ~/.vim/bundle && \
curl -LSso ~/.vim/autoload/pathogen.vim https://tpo.pe/pathogen.vim

After installation, you can enable Pathogen adding the following in your ~/.vimrc:


" Pathogen load
filetype off

call pathogen#infect()
call pathogen#helptags()

filetype plugin indent on
syntax on

To add python-mode plugin, all you need to do is to add the python-code code from its github repo to the “bundle” folder of .vim:


cd ~/.vim/bundle
git clone https://github.com/python-mode/python-mode.git

To get started with using python-mode in vim, open any vim file and read a short documentation on python-mode:


:help pymode

Leave a Reply

Your email address will not be published. Required fields are marked *