6

I dislike to have to reach up to the Escape key all the time. For a while I used the program xcape under Linux to map Caps lock to be both Control and Escape. However, I am currently working more and more on a Mac so I can’t have the same keybinding without much increased effort.

I thought that the key combination of Control-Space would be quite nice.

I tried to rebind with:

map <NUL> <ESC>
nmap <NUL> i

But that does not work correctly, often inserting the same text again.

  • 3
    An alternative to Esc key that is more 'reachable' is Ctrl-[ – tivn Apr 25 '15 at 15:58
  • Why would <Nul> be a ctrl-space? – Ben Apr 25 '15 at 23:38
  • Control-Space is a potentially difficult thing, since it's a signal which differnt TERMs send differently. It can be <C-Space> or <NUL>, if it's sent at all. – davidlowryduda Apr 26 '15 at 19:50
9

I found this map works for Ctrl-Space :

:nnoremap <C-@> i
:inoremap <C-@> <Esc>
  • Yes, I found that's what I have had to use for vim in terminals. The way to discover such things is to see what Vim produces when you type i<Ctrl-V><Ctrl-Space> or :<Ctrl-V><Ctrl-Space>. – joeytwiddle Dec 12 '15 at 4:53
  • Beware if you use Ubuntu 14.04, iBus may be intercepting the keystroke. Check the preferences of the little keyboard icon in the dock that lets you select language / keyboard input method, and change the mapping to something else (I went for <Ctrl-Alt-Space>). – joeytwiddle Dec 12 '15 at 4:56
4
nnoremap <C-Space> i
inoremap <C-Space> <Esc>
  • Does not do anything in normal mode exept beeping and in insert mode somehow triggers completion. :/ – Küstengold Apr 25 '15 at 14:37
  • 1
    Do you have existing mappings for c-space? These should work, I think, unless your vim is not recognizing the keystroke. – Ben Apr 25 '15 at 23:40
  • Should work for most modern terminals, however you can also map <C-@>like @tivn suggests, that works as well, the reason being both send the same key codes to vim. – Dhruva Sagar Apr 26 '15 at 23:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.