15

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.

DJMcMayhem
  • 17,581
  • 5
  • 53
  • 85
James Franco
  • 1,101
  • 1
  • 9
  • 15

1 Answers1

21

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.

Rich
  • 31,891
  • 3
  • 72
  • 139
DJMcMayhem
  • 17,581
  • 5
  • 53
  • 85