Paste code on VIM without auto-identation
If we try to paste some code on vim it will auto-indent the code making a mess.
We can avoid that with the vim paste mode.
:set paste
will start the paste mode and :set nopaste
will stop it.
But to make more easy I did a shortcut to toggle the paste mode:
nnoremap <leader>p :set invpaste paste?<CR>
With this when we press <leader>p
the paste mode will start so we can paste whatever we want and then we stop the paste mode with <leader>p
again.
I hope you guys enjoy the tip!
Written by Marcelo G. Cajueiro
Related protips
3 Responses
Thank you so much!
over 1 year ago
·
I similarly bind this to F2:
nnoremap <F2> :set invpaste paste?<CR>
set pastetoggle=<F2>
set showmode
over 1 year ago
·
This can be achieved automatically: https://coderwall.com/p/if9mda
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Vim
Authors
Related Tags
#vim
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#