Sunday, 17 April 2016

How to paste source code in Vim without losing formatting

When pasting code into Vim automatic indenting can occur and your code formatting will be incorrect. To stop this issue there are two options :

Paste option


Within vim
    : set paste

Vimrc function key mapping


It can be useful to have a mapping in your ~/.vimrc file to quickly allow enable/disable of the paste feature :
" Quickly enable/disable 'paste' option
set pastetoggle=<F10>

No comments:

Post a Comment