In order to be able add blank lines without going into insertion mode, I'm trying to map ALT-o
and ALT-O
to o<ESC>
and o<ESC>
I've tried the following in my .vimrc
map <M-o> o<ESC>
map <M-O> O<ESC>
and
map <ALT-o> o<ESC>
map <ALT-O> O<ESC>
and (as suggested below)
map <A-o> o<ESC>
map <A-O> O<ESC>
but none work. It just gives the usual behavior, as if ALT-o
had not been defined.
This is my first time altering the .vimrc
file, and I can't find where the documentation tells you how to designate the various keys. But I am able to verify that my .vimrc
file is being read, by including:
map <Enter> ihello<ESC>
Which sucessfully maps <Enter>
to inserting hello
and returning to command mode.
I'm using vim with cygwin.
Best Answer
To see what your terminal is sending when you press a key, switch to insert mode, press
Ctrl+V
, then the key. Most keys with most terminals send an escape sequence where only the first character is a control character;Ctrl+V
inserts the next character literally, so you get to insert the whole escape sequence that way.Different terminals send different escape sequences for some key combinations. Many terminals send the same character (
^O
) for bothCtrl+O
andCtrl+Shift+O
; if that's the case, Vim won't be able to distinguish between them.You mention that you're using Cygwin; which terminal you're running Vim in is the most pertinent information. If you're using the native Windows console, get yourself a better terminal. I recommend MinTTY for running Cygwin text mode applications in a terminal in Windows outside X, but Cygwin's Windows-native RXVT and PuTTYcyg are also good. (Also Console2 to run Windows console applications, but that's squarely off-topic here).