I am using macvim 8.1, the map command is

:inoremap <C-$> <End>

I also tried <C-4>, no working.

tried other number, can't work too (however CTRL-6 could work).

Also tried nnoremap, same result.

the :map <C-$> command shows

i <C-$>      * <End>

Normally Ctrl-Number produce a different key code. You can check like this:

Open Vim and change to insert mode. Then hit Ctrl-V followed by Ctrl-4 (or whatever you plan to map).

On Linux this produces the output ^\. Note that this is one character, usually displayed in light-blue. So Ctrl-4 is identical to Ctrl-\.

Tested with Vim 8.1 on Ubuntu in Gnome-Terminal (but should be true for all systems):

  • Ctrl-1 is not detected
  • Ctrl-2 is Ctrl-@ (hex 0x00)
  • Ctrl-3 is Ctrl-[ aka ESC
  • Ctrl-4 is Ctrl-\
  • Ctrl-5 is Ctrl-]
  • Ctrl-6 is Ctrl-^
  • Ctrl-7 is Ctrl-_
  • Ctrl-8 is Ctrl-? aka Delete used as Backspace
  • Ctrl-9 is not detected
  • Ctrl-0 is not detected
| improve this answer | |
  • 1
    Also, please see the faq: vimhelp.org/vim_faq.txt.html#faq-20.5 – Christian Brabandt Mar 29 '19 at 10:51
  • If Ctrl-3 is identical to ESC, I should expect vim quit insert mode to normal mode when Ctrl-3 is pressed, like ESC usuallly does, however, actually, 3 is input, so Ctrl-3 shouldn't be the same as ESC or Ctrl-[, should it? – chrisyue Apr 1 '19 at 2:16
  • @chrisyue <Ctrl-3> leaves insert mode. Tested in Vim, GVim, and the vi-editing-mode of Bash (Gnome-Terminal, XTerm). – Ralf Apr 1 '19 at 4:47
  • Well, on a mac at least <C-6> doesnt work, you have to use <C-^> – D. Ben Knoble Feb 27 at 6:03

I had a similar issue, when I wanted to map Ctrl+4 and Ctrl+6 keys, but those codes were not recognized. The output of Ctrl+vCtrl+4 was ^[[1;5t, which usually would lead to a mapping like e.g.

map ^[[1;5t <End>

but that did not work. The solution was to replace ^[ with <ESC> in the mapping command, like e.g.:

map <ESC>[1;5t <End>
imap <ESC>[1;5t <End>
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.