A major downside of Vim is that it is not as discoverable as your run-of-the-mill GUI editor, which makes it a lot less intuitive for the newcomer.
A major upside of Vim is that it compensates the aforementioned downside by bundling THE BEST DOCUMENTATION OF EVERY TEXT EDITOR EVER, which makes learning it from first principles a quick, painless, and rather enjoyable job.
Case in point: mappings are introduced in chapter 5 of the user manual, :help 05.4
, which links to the full mapping documentation at :help 40.1
, where :help key-notation
is linked to from the :help map-special-keys
section, which tells you that the correct representations of CTRL+[
and CTRL+]
in a mapping are:
<C-[>
<C-]>
Basically, spending just a few hours with the user manual, as everyone serious about using Vim should, would be enough to see that putting the following lines in your vimrc
is not going to do anything useful, let alone give you the desired functionality:
vnoremap CTRL+[ "+y
vnoremap CTRL+] "+p
Now, using the correct notation:
vnoremap <C-[> "+y
vnoremap <C-]> "+p
won't keep you out of trouble because <C-[>
happens to be synonymous with <Esc>
in Vim (and ASCII, etc.) and Vim uses it for a lot things under and over the hood. Like leaving visual mode, for starters. That means two things:
- mapping
<C-[>
also maps <Esc>
and vice-versa,
- mapping
<C-[>
, and therefore <Esc>
, to do something else than what it is supposed to is going to have lots of unforeseen side-effects.
You should find different keys to map to, at least for <C-[>
.
And start following the user manual ASAP: :help user-manual
.
<C-[>
, which is usually equivalent to<esc>
; it tends to cause all manner of problems<C-[>
but<C-]>
also does something useful. It jumps to the tag below the cursor. There are other keys to do the same (see:help CTRL-]
). I find this feature very powerful but, of course, you don't have to use it.