Configuring VIM as a (Python) IDE
While this is slanted towards configuring Vim for Python development this setup minus a couple of Python specific plugins (pep8, pydoc and pyflakes) would work well for any language.
This setup was influenced by Turning Vim into a modern Python IDE.
Vim Plugins
First of all, here is the list of Vim plugins we’ll be working with …
Autoclose
AutoClose automatically (and correctly) closes brackets, parenthesis, curly braces, single and double quotes.
Color-Sampler-Pack
Color-Sampler-Pack contains the top 100 rated color schemes on vim.sf.net.
Gundo
Gundo is a visual history browser.
Lusty
Lusty includes the LustyExplorer and LustyJuggler plugins for Vim which provide easy to use file and buffer management.
pathogen
pathogen allows plugins to be installed and managed within their own private directories.
pep8
pep8 checks your Python code against some of the style conventions in PEP 8.
pydoc
pydoc integrates viewing and searching Python documentation.
pyflakes
pyflakes highlights common Python errors like misspelling a variable name on the fly. It also warns about unused imports, redefined functions, etc.
ScrollColors
ScrollColors is a colorscheme Scroller/Chooser/Browser.
snipMate
snipmate provides tab completion for often-typed text.
SuperTab
SuperTab provides a tab completion for a variety of tasks.
virtualenv
virtualenv sets Vim paths correctly when working with virtualenvs, allows for activating and deactivating within a Vim session.
Dependencies
pyflakes
The only plugin that requires an external dependency is pyflakes. Let’s take care of that first.
sudo yum install pyflakes
Alternatively, you could install via pip.
sudo pip install pyflakes
git
We are going to manage our Vim modules with git. This allows for easy updating, rollback etc. of Vim plugins. Additionally, most Vim plugins are directly avaialable via github. See the vim-scripts page at github.
sudo yum install git
Repo Preperation
Create plugin directories.
cd $HOME
mkdir -p .vim/{autoload,bundle}
Initialize repo.
cd .vim git init
Install plugins as submodules to the repo.
git submodule add https://github.com/andrewle/vim-autoclose.git bundle/vim-autoclose git submodule add https://github.com/vim-scripts/Color-Sampler-Pack.git bundle/color-sampler-pack git submodule add https://github.com/sjl/gundo.vim.git bundle/gundo git submodule add https://github.com/sjbach/lusty.git bundle/lusty git submodule add https://github.com/cburroughs/pep8.git bundle/pep8 git submodule add https://github.com/vim-scripts/pydoc.vim.git bundle/pydoc git submodule add https://github.com/tpope/vim-pathogen.git bundle/pathogen git submodule add https://github.com/vim-scripts/ScrollColors.git bundle/scrollColors git submodule add https://github.com/ervandew/supertab.git bundle/supertab git submodule add https://github.com/jmcantrell/vim-virtualenv.git bundle/vim-virtualenv git submodule init git submodule update git submodule foreach git submodule init git submodule foreach git submodule update
Create symlink in order to autoload pathogen.
ln -s '../bundle/pathogen/autoload/pathogen.vim' autoload/pathogen.vim git add autoload
Move vimrc under repo and symlink it under home.
mv $HOME/.vimrc . ln -s './.vim/.vimrc' $HOME/.vimrc git add .vimrc
Commit changes to repo.
git commit -m "Initial commit."
vimrc file
" pathogen let g:pathogen_disabled = [ 'pathogen' ] " don't load self call pathogen#infect() " load everyhting else call pathogen#helptags() " load plugin help files " code folding set foldmethod=indent set foldlevel=2 set foldnestmax=4 " indentation set autoindent set softtabstop=4 shiftwidth=4 expandtab " visual highlight Normal ctermbg=black set background=dark set cursorline set t_Co=256 " syntax highlighting syntax on filetype on " enables filetype detection filetype plugin indent on " enables filetype specific plugins " colorpack colorscheme vibrantink " gundo nnoremap <F5> :GundoToggle<CR> " lusty set hidden " pep8 let g:pep8_map='<leader>8' " supertab au FileType python set omnifunc=pythoncomplete#Complete let g:SuperTabDefaultCompletionType = "context" set completeopt=menuone,longest,preview
bashrc
Additionally, I suggest making the following changes to .bashrc
export EDITOR=/usr/bin/vim
Reference
Autoclose
Links:
vim.org page
github page
Reference Files:
bundle/vim-autoclose/README
bundle/vim-autoclose/plugin/autoclose.vim
Color-Sampler-Pack
Links:
vim.org page
github page
Reference Files:
bundle/Color-Sampler-Pack/README
bundle/Color-Sampler-Pack/plugin/color_sample_pack.vim
Gundo
Links:
main page
vim.org page
github page
Reference Files:
bundle/gundo/README.markdown
bundle/gundo/plugin/gundo.vim
Help:
:help gundo
Lusty
github page
LustyExplorer
Links:
vim.org page
github page
Reference Files:
bundle/lusty/doc/explorer-vim.writeup
bundle/lusty/plugin/lusty-explorer.vim
LustyJuggler
Links:
vim.org page
github page
Reference Files:
bundle/lusty/doc/juggler-vim.writeup
bundle/lusty/plugin/lusty-juggler.vim
pathogen
Links:
vim.org page
github page
Reference Files:
bundle/pathogen/README.markdown
autoload/pathogen.vim
pep8
Links:
vim.org page
github page
Reference Files:
bundle/pep8/README.rst
bundle/pep8/pep8.py
pydoc
Links:
vim.org page
github page
Reference Files:
bundle/pydoc/README
bundle/pydoc/ftplugin/python_pydoc.vim
pyflakes
Notes:
This depends on the external pyflakes Python module. Install via yum or pip.
Links:
vim.org page
github page
Reference Files:
bundle/pyflakes-pathogen/README.rst
bundle/pyflakes-pathogen/ftplugin/python/pyflakes.vim
See Also:
:help quickfix
ScrollColors
Links:
vim.org page
github page
Reference Files:
bundle/ScrollColors/README
bundle/ScrollColors/plugin/ScrollColor.vim
snipMate
Links:
vim.org page
github page
Reference Files:
bundle/snipmate/README.markdown
bundle/snipmate/plugin/snipMate.vim
Help:
:help snipMate
SuperTab
Links:
vim.org page
github
Reference Files:
bundle/supertab/plugin/supertab.vim
Help:
:help supertab
virtualenv
Links:
vim.org page
github page
Reference Files:
bundle/vim-virtualenv/README.mkd
bundle/vim-virtualenv/plugin/virtualenv.vim
Help:
: help virtualenv
Check this: https://github.com/klen/python-mode
Given that your previous post mentioned installing ipython, you might be interested in taking a look at vim-ipython: using this plugin, you can send lines or whole files for IPython to execute, and also get back object introspection and word completions in Vim, like what you get with: object? and object. in IPython.
There are links to a couple of videos of this plugin in action linked from that Github page.
Honestly, I feel a bit bad about this one. I tried it, couldn’t get it to “work out of the box”, briefly looked at the docs and still couldn’t get it working. I should have looked into it further and perhaps submitted a bug report but the rest of my setup has worked so well that I just put it off. However, I’ll take a look into it again. Do you know if there are any conflicts with the plugins I mentioned that would cause any issues or conflicts?
You need IPython 0.11 or later with ZeroMQ enabled. I only use a subset of the plugins you describe, but I don’t think there should be issues – if there are – I’d love to find out and fix them.
One common issue that folks were having – when using terminal vim – is that the ctrl-S shortcut is disabled by their terminal. The readme addresses the various ways of disabling that.
I actively support vim-ipython – so if you have any issues, please report them using the github interface, and I usually get back to people within a day.