Thursday, December 03, 2009

Save with CTRL-S using VIM and copy/paste with CTRL-C, CTRL-V

Oh now this has got to be the best VIM find in years. I love VIM but get sick of copying from a web browser and having to visual paste in strange ways. It's my one holdover from Windows, the desire to use CTRL-C to copy and CTRL-V to paste. It turns out that this is easily remedied by modifying your .vimrc file and adding VIM mappings.

nmap <C-V> "+gP
imap <C-V> <ESC><C-V>i
vmap <C-C> "+y

That's it. Now enjoy the most standard shortcuts in your favorite VIM editor. The mappings looked so easy that I thought I'd try one of my own. Another thing that causes my fingers to grow weary is saving. The typical sequence is: press escape, then :w enter. I save all the time because I'm paranoid and I miss CTRL-S which is so much easier on the hands.

map <C-S> <ESC>:w<CR>
imap <C-S> <ESC>:w<CR>

Oh yes it is a sweet discovery!

No comments: