0

I recently discovered vim has :term command to open terminal inside vim. I want to create a keyboard shortcut of Ctrl+` just like in visual studio code. But :map <C-`> :term doesn't do anything. Can anybody help. I am on windows using gvim.

Kshitij Dhakal
  • 816
  • 12
  • 24

2 Answers2

2

You can't.

The problem is that ctrl` won't be treated as a different key.

Only @, A-Z, [, \, ], ^ and _ map to ASCII characters (0 through 31 respectively) when combined with ctrl

To check this, You can try the combination ctrlv`

It'll print ` itself.

You'll have to find some other key combination for this.

sudo bangbang
  • 27,127
  • 11
  • 75
  • 77
1

TL;DR: You cannot use this key combination; choose another one.

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. http://groups.google.com/group/vim_dev/browse_thread/thread/626e83fa4588b32a/bfbcb22f37a8a1f8

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
  • 167,457
  • 16
  • 250
  • 324