Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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>


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.

share|improve this question
It sounds like your terminal isn't passing the alt sequences at all. Do any other known sequences work? What about trying Ctrl? What terminal are you using? – Caleb Jun 10 '11 at 14:01
I'm using vim on cygwin, but I have made other scripts work, as my edit details. – Eric Wilson Jun 10 '11 at 14:06
Ctrl works, sort of. It doesn't seem to let me distinguish between <C-o> and <C-O>. – Eric Wilson Jun 10 '11 at 14:11
Giles answer is right on track. You should definitively switch to a more capable terminal. These problems should disappear and you'll get your keys back! – Caleb Jun 11 '11 at 7:40
up vote 7 down vote accepted

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 both Ctrl+O and Ctrl+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).

share|improve this answer
Excellent. Thank you very much – GMaster Oct 19 '14 at 10:38

The M(eta) key is the windows-button. It is just <A-o>.

share|improve this answer
This also doesn't work. – Eric Wilson Jun 10 '11 at 13:44
This isn't always the case, on different keyboard layouts and language locales they are often different. – Caleb Jun 10 '11 at 14:02
@Caleb is there any documentation for this? – Eric Wilson Jun 10 '11 at 14:12
I tried map <A-o> o<ESC> and it worked for me. If you put it in your .vimrc, did you reload it? – Martin Ueding Jun 10 '11 at 16:59
The asker already stated in their question that they verified the file was being loaded. This isn't relative to the user since they are on windows, but you can see different Meta/Win/Alt key configurations in the xkb geometry/symbol/keycode files. You will notice even in the gnome keyboard layout options there are several common ways to remap between Alt/Win/Meta. One of the reasons this exists is because of the disparity in base layouts. – Caleb Jun 11 '11 at 8:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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