tags:

views:

194

answers:

3

I'd like to use two "controls" as a toggle key to switch between normal mode and insert mode in Vim. So I add the following two lines into my .vimrc

nmap <C-><C-> i
imap <C-><C-> <ESC>

But it doesn't work. What's wrong with the above two lines?

A: 

That's definitely not going to work. You could use an F key instead.

graywh
+1  A: 

It seems you are trying to map Ctrl+Space to toggle insert mode.

nnoremap <C-space> i
imap <C-space> <Esc>

(Came from this Vim tip (marked obsolete, but there's a link to a more rich document on avoiding which includes the tip).)

Remember that this is not guaranteed to work across all terminals and platforms. Some terminals and platforms may eat a given Ctrl+something shortcut, while others don't, so find one that works in your environment.

Håvard S
That will only work in gvim. Terminal vim has be told what control character is generated by your ctrl-space.
graywh
A: 
nnoremap <silent><C-space> :startinsert
inoremap <silent><C-space> <C-O>:stopinsert
Nikolay Frantsev