How can I keep the code formated as original source when I paste them to vim?
This is a portion of my .vimrc file.
" when opening a Python file, use spaces instead of tabs (et, expandtabs), " use 4 spaces as tabulation (ts=4, tabstop), use 4 spaces when adding " a tabulation automatically (sw=4, shiftwidth) and thread 4 spaces as " a tabulation when deleting (softtabstop=4) au FileType python set et ts=4 sw=4 softtabstop=4 autocmd BufRead *.py set makeprg=python\ -c\ \"import\ py_compile,sys;\ sys.stderr=sys.stdout;\ py_compile.compile(r'%')\" autocmd BufRead *.py set efm=%C\ %.%#,%A\ \ File\ \"%f\"\\,\ line\ %l%.%#,%Z%[%^\ ]%\\@=%m autocmd BufRead *.py nmap <F5> :!python %<CR>
It works very well for editing python. However, when I need to paste pre-indented python code into a python file from my clipboard buffer I end up with something that looks like this:
class GlobalOptions: def __init__(self): self.DebugLevel = 0 def __repr__(self): return "<GO>"
This occurs even if I use ':set noautoindent' .
Is there a simple way to toggle between intelligent autoindenting of python files and a raw entry mode that can be used for pasting code?
I'd be happy to experiment with someone elses .vimrc file if it avoids this problem.
I have encountered this problem on vim 6.3, 7.0, 7.1 running on Debian, RedHat and Ubuntu respectively.