vim terminal - cannot generate C-Space (C-@)

47 views
Skip to first unread message

mckel...@gmail.com

unread,
Dec 21, 2020, 11:46:46 AM12/21/20
to vim_use
Hi,

Thank you for awesome vim!

In a vim terminal I cannot seem to get a C-@ key.
This works fine in vim itself and at a normal shell prompt, but not inside a vim terminal.
Is this supported ?  Is there something I need to add (tmap etc.) ?

thanks for any/all help,
-m

mckel...@gmail.com

unread,
Dec 21, 2020, 4:10:40 PM12/21/20
to vim_use
Hi,

Just more info, I am using version 8.2.2184, on Ubuntu 18.04

thx,
-m

mckel...@gmail.com

unread,
Jan 13, 2021, 12:17:14 PM1/13/21
to vim_use
Hi again,

Just fyi, I think adding this helps -

    tnoremap <C-@> <C-Space>

Not sure why, and will keep trying different things.

take care,
-m

Tony Mechelynck

unread,
Jan 14, 2021, 3:05:59 AM1/14/21
to vim_use
There are keystrokes which are difficult to get on some keyboard
layouts or on some terminals. A workaround is to define a mapping with
the desired keystroke as {rhs} and something which you know how to
type, but don't need in Vim, as {lhs}. Here is an example:

When I started using Vim, I couldn't find how to get Ctrl-] on my
AZERTY keyboard. Now that's an extremely useful keystroke in Vim: in
Normal mode it finds tags (and when in the help, it follows hotlinks),
and in Insert mode it triggers an abbreviation (if there is one) for
whatever has just been typed without inserting an additional
character. Finally I added the following to my vimrc:

if exists(':map') == 2
map <F9> <C-]>
map! <F9> <C-]>
endif

Now I can follow help links with just F9 (in +eval buids because of
the :if wrapper; in any +mouse builds I can also use a double-click,
and all builds are compiled with +mouse nowadays). Years later, I
found how to get Ctrl-] on my keyboard: it's Ctrl-AltGr-$ where $ is
the key at the end of the top alphabet row, two keys to the right of
the P in AZERTYUIOP. Now that's a fairly complicated (three-finger)
keystroke combination, so I keep using F9 (and sometimes a double
click).

Maybe you can easily get Ctrl-] on your keyboard; but similar mappings
can be used for any difficult-to-reach keystrokes, keystrokes not
available on your keyboard layout in one or more of Vim's modes, or
even just keystrokes for which an alternative is desired.

Best regards,
Tony.

BPJ

unread,
Jan 14, 2021, 5:40:15 AM1/14/21
to vim_use
Den tors 14 jan. 2021 09:06Tony Mechelynck <antoine.m...@gmail.com> skrev:

> There are keystrokes which are difficult to get on some keyboard
> layouts or on some terminals. A workaround is to define a mapping with
> the desired keystroke as {rhs} and something which you know how to
> type, but don't need in Vim, as {lhs}.

Since I have cerebral palsy it is difficult for me to press more than one key at the same time, especially with the same hand, so I have remapped most commands which involve pressing two keys simultaneously to sequences starting with an F-key which I can press one after another. This was before I discovered sticky keys, but I still prefer my remappings to sticky keys. In fact this was the reason I started to use Vim in the first place, although it is not the main reason I stay with Vim and do almost everything in Vim. :-) I also use other applications with a Vi(m)-like interface like Zathura, or plugins which allow the use of Vi(m) style key sequences in things like web browsers and mail clients. I also use several key maps so that I easily can type "special" characters and other scripts — including a hack so that I quickly can switch keymaps just by pressing a sequence of two keys.[^1] I use a mouse too — actually a trackball attached to my laptop — but precision pointing, and GUIs in general, just isn't my thing!

[^1]: <https://git.io/JtJI3> I haven't kept the keymaps in that repo up to date with what's on my local machine but those autoload functions for switching keymaps and defining mappings to do it are the same. Basically I type something like <F11>g to switch to a keymap for Ancient Greek, then I type <F11><F11> to disable it *or* switch to the previously used keymap if a keymap was active when I switched to Greek, then I can type <F11><F11> again to switch back to Greek, e.g. <F11>x to switch to a mapping between modified X-SAMPA <https://w.wiki/uKk> and Unicode IPA, or <F11>0 (zero) to switch to no keymap at all, all without leaving insert mode. This is achieved with two per-buffer variables which store the previous and the current value of the 'keymap' option, with the empty string being a possible value meaning that no keymap is active. There also is a helper function so that I can define multiple mappings with a common prefix trough a Dictionary in my .vimrc.

Reply all
Reply to author
Forward
0 new messages