How can I copy the semicolon Ctrl + to add a semicolon to the end of the line?

I am trying to match a press of [ctrl] + [semicolon] in insert mode to go to the end of a line and add a semicolon. This is what I find that I do a lot after installing the surround plugin.

I tried to execute this command

inoremap <c-;> <esc>A;<esc> 

but when I try it, it exits insert mode and goes into command mode. Trying with another d modifier also gives the same result.

Can a semicolon not be displayed using a modifier? What am I doing wrong?

+7
vim
source share
2 answers

I didn’t read your question carefully, I just saw that your mapping brought you out of insert mode and the last <esc> ... of my error.

Do you want to display ctrl+; vim cannot capture key code. There is some key combination that cannot be matched in vim. ; - one of them, another example like ctrl+= .

so you can choose a different mapping.

btw, you can try in insert mode press ctrl-v , then specify a key combination to see if it can be used.

+4
source share

Depending on your terminal, you can configure mappings. For example, if you are using urxvt, in ~/.Xresources add:

 URxvt.keysym.C-semicolon: \033[; 

And in ~/.vimrc add:

 map <Esc>[; <C-Semicolon> map! <Esc>[; <C-Semicolon> 

Then you should be able to match it (not tested):

 inoremap <c-Semicolon> <Esc>A;<Esc> 

I use this to display the movement of a broken window like this (this works for me):

 noremap <C-Semicolon> <Cw>l 
+3
source share

All Articles