Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Describe your customized Vim editor for Python/Django development?

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)

I am not going to post my whole .vimrc file here, but I have a similiar setup as you. This is less Python/Django specific though, except for some custom snippets for snipMate and python-mode. Here the vim plugins I am using:

  • Pathogen: better organized vim plugin structure in .vim dir
  • comments.vim: faster language specific commenting with ctrl-c and ctrl-x
  • NERDTree
  • NERDTree tabs
  • syntastic: Syntax checking plugin (for me mainly used for non-python code)
  • surround.vim and autoclose.vim: Easier handling of brackets, opening and closing tags etc.
  • matchit: extends the % command to also match and circle through for example html tags. For circling through Python code statements (eg. if-elif-else) you can download python_match.vim and put it into your ftplugin/python/ dir. I put it into ~/.vim/bundle/matchit/ftplugin/python/
  • python-mode: Great plugin for Python editing. Has automated pyflakes/pep8 checking (or pylint if you want) on file save. I deactivated the auto complete via let g:pymode_rope = 0 in my .vimrc file though, since it lagged for me on each file save. Also the syntax highlighting is extended for python code.
  • snipMate (custom snippets for python follow below)
  • tagBar: I can't live without an outline for huge code files.

Some custom python snippets I use quite frequently:

snippet #utf
    # -*- coding: utf-8 -*-

snippet ds
    """
    ${1: }
    """
# just the first (or last) three quites for the docstring
snippet dss
    """${1: }
# For file headers
snippet dsfile  
    """
    :File: ${1:`Filename('$1.py', 'foo.py')`}
    :Author: ${2:`g:snips_author`}
    :Description: ${3}
    """
snippet pdb
    import pdb
    pdb.set_trace()