9
Mapping to (discuss.tchncs.de)

Hi, I want to try Neovim and am currently setting it up. I want an easier way to type or <C-[>, so I added these keymaps:

vim.keymap.set("", "<C-Space>", "<C-[>")
vim.keymap.set("!", "<C-Space>", "<C-[>")

But this does weird stuff: In insert, visual and normal mode it seems to work and pressing CTRL+Space brings me back to normal mode or does nothing. But when entering a colon-command, pressing CTRL+Space acts as if I had pressed Enter. When typing "r" (single character replace) and then CTRL+Space, it replaces the character by a space, as without the mapping.

The same applies when mapping other keys than instead (the terminal seems to send correctly), or when mapping to instead of <C-[>.

What's going on here and how can I get the mapping to work? Thanks for any help!

you are viewing a single comment's thread
view the rest of the comments
[-] Oinks 2 points 4 days ago* (last edited 4 days ago)

You can also use <C-C> to quit command mode instead (and this one works in keymaps). It also works in Insert mode but doesn't trigger the InsertLeave event, which might upset some plugins.

As far as I know the character pending mode thing that r does is a bit unique in that it isn't insert mode, but also not quite replace or operator pending mode. If there's a way to remap any key to work with r then I'm not aware of it.

Have you considered instead remapping <Esc> on an OS level? The XKB option caps:escape turns your Caps Lock key into an additional Escape key, which is even easier to type than <C-Space>.

this post was submitted on 22 Oct 2025
9 points (100.0% liked)

Neovim

2637 readers
1 users here now

founded 2 years ago
MODERATORS