Remap Ctrl-D in vim

I want to reassign another key combination, say CTRL - G , to function as CTRL - D (note: not the same as S - Down / PageDown / CTRL -. F )

What I still have:

nmap ^G :exe 'normal '.&scroll.'^E<CR>' 

Raising my vim command mode and typing it, it works fine. However, when I save my .vimrc and reload vim, I get the following error when I press CTRL - G :

 E114: Missing quote: ' E15: Invalid expression: 'normal '.&scroll.' 

He seems to be stuck in not evaluating ^ E accordingly. However, I did not fully use the use or any other way of specifying CTRL - E. What am I missing here?

+4
source share
2 answers

^G and ^E are special characters and do not work when you put them in .vimrc . You need to use <Cg> and <Ce> , but since your Ctrl + E is placed inside the line, you need to escape and write \<Ce> . You also need to use double quotes instead of single quotes, otherwise you won’t be able to escape.

In another note, you should probably use nnoremap instead of nmap , so if you remake <Ce> to another location, <Cg> will still behave like the original <Ce> .

+5
source

I think you can just write <CE> for CTRL - E.

+2
source

Source: https://habr.com/ru/post/1444444/


All Articles