Describe your customized Vim editor for Python/Django development?


Question

I've recently switched entirely to Vim for all my Python/Django development. It took me a lot of time to customize it to the point it is today, and God knows how hard it was for me to find help regarding the best vim plugins out there suited for Python/Django development.

I decided to ask this question so people like me could benefit directly from your experience: You've built the perfect Python/Djangoish Vim editor? Describe it for us (plugins, scripts, customized .vimrc, colorschemes ..etc).

Thanks

My Configuration

Ok, this is my own configuration. actually I've chosen to create a simple Vim configuration so I can master the little number of plugins I've chosen to install instead of make a big stack of plugins that I'll never master nor use. This is the list of the plugins I use the most:

  • NERDTree for file management,
  • SnipMate which is an implementation of TextMate's snippets feature,
  • Code Completion is handled with Omnicompletion which come by default in Vim,
  • Pydoc to integrate the Python Documentation into Vim,
  • TagList for source code browsing, very useful in large files.
  • Pyflakes script to highlight Python code on the fly with warnings

Also I've created a python.vim file in $HOME/.vim/ftplugin/ containing this script so I can run python code from Vim just by running Shift+e:

" Execute file being edited with <Shift> + e:
map <buffer> <S-e> :w<CR>:!/usr/bin/env python % <CR>

Also I've collected some useful .vimrc customizations:

set nocompatible    " use vim defaults
set number          " show line numbers
colorscheme desert
set tags=tags;$HOME/.vim/tags/ "recursively searches directory for 'tags' file
set expandtab       " tabs are converted to spac
set tabstop=4       " numbers of spaces of tab character
set shiftwidth=4    " numbers of spaces to (auto)indent
set showcmd         " display incomplete commands
set hlsearch        " highlight searches
set incsearch       " do incremental searching
set ruler           " show the cursor position all the time
set numberwidth=4   " line numbering takes up 5 spaces
set ignorecase      " ignore case when searching
set nowrap          " stop lines from wrapping
filetype plugin indent on " turn on the indent plugins
syntax on                 " syntax highlighing
" TagList Plugin Configuration
let Tlist_Ctags_Cmd='/usr/bin/ctags'       " point taglist to ctags
let Tlist_GainFocus_On_ToggleOpen = 1      " Focus on the taglist when its toggled
let Tlist_Close_On_Select = 1              " Close when something's selected
let Tlist_Use_Right_Window = 1             " Project uses the left window
let Tlist_File_Fold_Auto_Close = 1         " Close folds for inactive files
" Omnicompletion functions
autocmd FileType python set omnifunc=pythoncomplete#Complete
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
autocmd FileType html set omnifunc=htmlcomplete#CompleteTags
autocmd FileType css set omnifunc=csscomplete#CompleteCSS
au FileType py set expandtab
au FileType py set foldmethod=indent
map <F2> :previous<CR>                  " map F2 to open previous buffer
map <F3> :next<CR>                      " map F3 to open next buffer
map <F4> :NERDTreeToggle<CR>            " map F4 to open NERDTree
map <F5> :TlistToggle<CR>               " map F5 to toggle the Tag Listing
map <silent><C-Left> <C-T>              " taglist - map Ctrl-LeftArrow to jump to the method/property under your cursor
map <silent><C-Right> <C-]>             " taglist - map Ctrl-RhitArrow to jump back to your source code
map <silent><A-Right> :tabnext<CR>      " map Alt-RightArrow to jump to the next tab
map <silent><A-Left> :tabprevious<CR>   " map Alt-LeftArrow to jump to the previous tab
1
27
10/27/2010 11:22:54 AM

I don't really have much Django specific mods, although I have given the jinja2 syntax a higher priority than the django template syntax.

For Python specifically:

  • For Python syntax checking I use PyFlakes with highlight SpellBad ctermbg=darkred
  • Sometimes (rarely) I feeld the need for autocompletion and in that case I use Eclim
  • For the rest, the default stuff. Tab size 4, soft tabs, etc...

Vim Settings:

  • 256 Color scheme desert256

    if ((&term == 'screen') || (&term == 'screen-bce') || (&term == 'xterm')) 
        set t_Co=256                                                          
        set t_Sb=^[[4%dm                                                      
        set t_Sf=^[[3%dm                                                      
        colo desert256                                                        
    endif
    
  • Lots of tabs (tabe, tabn)
  • Lots of splits (both vertical and horizontal)
5
10/26/2010 9:45:28 PM

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow
Icon