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.

  • 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

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).


If Control+V followed by ALT-x shows ^[x (type in terminal) you can fix it with this small script from vim.wikia.com:

for i in range(97,122)
  let c = nr2char(i)
  exec "map \e".c." <M-".c.">"
  exec "map! \e".c." <M-".c.">"

Add to .vimrc for all alt key mappings.


This works for me on Ubuntu 16.04 xfce terminal (and alacritty rust terminal)

Set ultisnip snippet trigger to Meta-/ (just like emacs snippet)

let g:UltiSnipsExpandTrigger="^[/"

Here's now I type ^[/ in vim

In insert mode Ctrl-V Alt-/

(Meta is the Alt key on my PC keyboard)


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

  • 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 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.