I used to get annoyed when pasting text into a Vim window as each line would indent one more tab than the last line.
To fix it I used to add set noautoindent
in /etc/vimrc
, however this unsurprisingly turns off auto indenting, which is a useful feature for normal typing.
Today I came up with a definitive solution to this by setting a key binding for ‘pastetoggle’. Now in vimrc is the line:
set pastetoggle=<F11>
..meaning that should I need to paste in some formatted text, I simply press F11 when in insert mode to enter paste mode, paste my text in and then F11 again to exit paste mode (but still be in insert).
One could also do :set paste
and :set nopaste
, but this was far too much typing for my liking.
Note: This is working for me in Vim 7.0
Leave a Reply