Sunday 18 October 2009

Notepad-compatibility for copy and paste in vim and gvim

Unfortunately, even us, Linux die-hards, get used to other OS conventions, such as copy-pasting with Control-C and Control-V. Maybe because in some other OS, by design, you need to spend hours copying and pasting.

In any case, if you want your Vim and GVim on your Linux box responding to Control-C and Control-V for these operations you need to map these key combinations to their internal counterparts, "+y and "+gP respectively.

In order to achieve this, you need just go to your home directory and add to the .vimrc file there the following three lines:

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

A final piece of advice: use it with care! Copy/paste operations do not increase the amount of information but increase its size.

No comments:

Post a Comment