MacOS 10.14.6

I'm using VIM as text editor for a few weeks, with both Terminal and iTerm2

I could write character dependent on hitting key alt (left alt key in iTerm) without problem


  • alt-3 gave the the character "#"
  • alt-5 gave the the character "["
  • alt-6 gave the the character "]"

But suddenly, it changed and now when hit those shortcuts, it does not write the corresponding character with the left alt key and quits insert mode instead (although the command with the desired output work with the right alt key in iTerm2. Moreover combinations with both right and left alt key are also working fine in Terminal). I think that this change came after Vim or iTerm2 asked me if I wanted to change some shortcuts and I (stupidly) responded yes.

So i conclude that pressing suddenly seems to map to the command Esc (and not the character "#", How do I change that mapping

I tried the following command without success:

:unmap <Alt-3>
:unmap <Alt-3> Esc
:unmap <press Alt-3>
:unmap <press Alt-3> Esc

:map  <A-3> #
:map! <A-3> #
:map  <A-"> #
:map! <A-"> #
:set timeout timeoutlen=5000 ttimeoutlen=250

I want be able to write the character "#" with the shortcut Alt-3 (left alt button) in iTerm2

Did I change something by mistake? What should I do to fix the problem? Should I change the ~/vimrc file

  • Hi. Welcome to Vi/Vim SE. Have you read the help docs? (Enter :h :map). If you're trying both map and map! it seems that you're not even sure what mode you want to do the mapping in. Similar comment regarding press. It will be easier to help you if you familiarize yourself with that documentation.
    – B Layer
    Aug 26, 2019 at 19:25
  • I don't think this is a problem with Vim, more likely an iTerm configuration. See this post about handling of the Meta key, although in your case using ,ESC+ is probably what's causing your problem, so you might want to switch to one of the other settings, see if that fixes it...
    – filbranden
    Aug 26, 2019 at 19:49
  • 1
    Many thanks @filbranden! That posted helped a lot. I could solve the problem be going to Iterm2 > Preferences > Profiles > Keys and there setting "Left Option (alt) Key from "Esc+" to "Normal"
    – ecjb
    Aug 26, 2019 at 20:09
  • Welcome to Vi and Vim! We do generally discourage cross-posting on the stack-exchange network, to keep closer to a « single source of truth » model
    – D. Ben Knoble
    Aug 26, 2019 at 20:40
  • Answered on stackoverflow.com/q/57649240/9447571
    – filbranden
    Aug 26, 2019 at 23:04


Browse other questions tagged or ask your own question.