Below is a file that I've dropped in my ~/.vim/plugins directory. I named it pyvi.vim. It let's me toggle between "normal" settings and "python" settings:
function! PyVi()
if exists('g:pyvi_on')
unlet g:pyvi_on
set noexpandtab
set textwidth=78
set tabstop=8
set softtabstop=0
set shiftwidth=8
set noautoindent
unmap <Leader>r
echo "Pyvi off."
else
let g:pyvi_on = 1
set expandtab
set textwidth=79
set tabstop=8
set softtabstop=4
set shiftwidth=4
set autoindent
map <Leader>r :!nosetests<cr>
echo "Pyvi on."
endif
endfunction
command Pyvi call PyVi()
Now, when I'm in vim, if I issue the command "Pyvi" once, it set's a bunch of settings for me that are specific to making pylint happy. If i issue the same command again, it will undo my settings changes. I also added the following to my .vimrc to create a mapping for \-d.
map <Leader>d :Pyvi<cr>
Pretty simple and yet effective.