5

I'm trying to re-map tagbar toggling with <C-&> that I get used to when working with IDEs.

But setting

execute "nnoremap <C-&> :TagbarToggle<CR>"

does not have the desirable effect. When pressing 3 keys at once CTRL-SHIFT-7 where SHIFT-7 stands for & it essentially acts as simple pressing & without CTRL.

Is there a way <C-&> to behave differently other than &?

St.Antario
  • 1,117
  • 3
  • 14
  • 27

2 Answers2

5

According to one of our former mods, the answer is no:

Sending Control with a character from the 2nd column is useless. Control clears the 7th bit, but this is already 0, so Control+# will just send "#".

Notice that & in the second column has binary representation 01 00110, so clearing the 0 doesn't help.

D. Ben Knoble
  • 26,070
  • 3
  • 29
  • 65
4

Due to the way that the keyboard input is handled internally, this unfortunately isn't generally possible today, even in GVIM. Some key combinations, like Ctrl + non-alphabetic cannot be mapped, and Ctrl + letter vs. Ctrl + Shift + letter cannot be distinguished. (Unless your terminal sends a distinct termcap code for it, which most don't.) In insert or command-line mode, try typing the key combination. If nothing happens / is inserted, you cannot use that key combination. This also applies to <Tab> / <C-I>, <CR> / <C-M> / <Esc> / <C-[> etc. (Only exception is <BS> / <C-H>.) This is a known pain point, and the subject of various discussions on vim_dev and the #vim IRC channel.

Some people (foremost Paul LeoNerd Evans) want to fix that (even for console Vim in terminals that support this), and have floated various proposals, cp. https://groups.google.com/forum/#!topic/vim_dev/Ym6D-kWIsyo

But as of today, no patches or volunteers have yet come forward, though many have expressed a desire to have this in a future Vim release.

Ingo Karkat
  • 17,819
  • 1
  • 45
  • 61