The reason why
:nnoreamp ^E 3^E
Doesn't work is because ^E
is two separate characters. You can tell because you have to hit the arrow keys twice to move backwards past it. So you are really remapping ^ E to 3 ^ E, which is probably not what you want to do, especially since ^
doesn't take a number argument.
When you use a digraph, this is displayed as two characters, but it is a single character, which you can tell because backspace and arrow keys treat it as a single character. The other way you can tell is because vim will (probably) display it as a different color. For me, this digraph appears blue, but it might be different for you depending on your setup.
The answer you came up with works but it isn't the ideal way or the idiomatic way. A better way of entering a digraph is with <C-v>
, rather than <C-k>
. With <C-k>
you have to hit ctrl+e twice, but if you were to use <C-v>
you could just hit ctrl+e one time and it would work. So that would look like
:nnoremap<space><C-v><C-e><space>3<C-v><C-e>
Which is a little easier than what you were doing. An even better way (IMO) is to use an ASCII literal, rather then a digraph. I prefer this method since:
It keeps your .vimrc
tidier.
It is easier to understand what is pressed vs what is sent to vim.
It's more readable.
It avoids nasty unicode unprintables.
You were close with your initial try of
:nnoremap <Ctrl-e> 3<Ctrl-e>
You just got one minor detail wrong. <Ctrl-e>
does not describe any keystroke that vim can understand. You should have written
:nnoremap <C-e> 3<C-e>
:help key-notation
ctrl-k
but when I tried:helpgrep ctrl-k
I got nothing. Helpgrep is case sensitive so I should have used:helpgrep ctrl-k\c