9

I am trying to map my Ctrl and plus sign together. This is what I am trying in my vimrc:

nnoremap <C-=>    : echo "Hello" <CR> 

However it seems like the mapping is not being triggered. Any suggestions on what I might be doing wrong? I am using macvim.

16

Unfortunately, there's no reliable way of mapping Ctrl-=.

Because of the way that ctrl+key chords interact with the terminal and are represented internally, the only Ctrl-mappings that Vim is guaranteed to be able to detect are the ones defined in the ASCII standard. Here is the full list of such ctrl+key combinations, and the byte each represents.

Ctrl-@                 0x00            NUL
Ctrl-A to Ctrl-Z       0x01 to 0x1A
Ctrl-a to Ctrl-z       0x01 to 0x1A
Ctrl-[                 0x1B            ESC
Ctrl-\                 0x1C
Ctrl-]                 0x1D
Ctrl-^                 0x1E
Ctrl-_                 0x1F
Ctrl-?                 0x7F            DEL

However, note that most of these are already have a function in Vim, and some are essentially identical to/indistinguishable from other keystrokes. e.g. CTRL-M has the same keycode as Enter, so if you map either of those you are also unavoidably mapping the other.

Source: Vim-FAQ

You might be able to get around the restrictions above by configuring your terminal to send a certain byte-sequence for your mapping, like in this stack-overflow thread, but that will definitely be a pain. Personally, I'd rather just pick a different mapping.

This might eventually be fixed, but it's unlikely, since Vim relies upon the terminal it's running in. However, there's a good possibility this will work in Neovim. I don't know if that works right now or not.

  • 1
    Nice, I will be linking people to this in the future. – Tumbler41 Jul 19 '16 at 18:19

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.