I've installed the vim by homebrew, current version and installation information is as below:

VIM - Vi IMproved 8.1 (2018 May 18, compiled Feb 19 2019 11:57:49)
macOS version
Included patches: 1-950
Compiled by Homebrew
Huge version without GUI.  Features included (+) or not (-):
+acl               +extra_search      +mouse_netterm     +tag_old_static
+arabic            -farsi             +mouse_sgr         -tag_any_white
+autocmd           +file_in_path      -mouse_sysmouse    -tcl
+autochdir         +find_in_path      +mouse_urxvt       +termguicolors
-autoservername    +float             +mouse_xterm       +terminal
-balloon_eval      +folding           +multi_byte        +terminfo
+balloon_eval_term -footer            +multi_lang        +termresponse
-browse            +fork()            -mzscheme          +textobjects
++builtin_terms    +gettext           +netbeans_intg     +textprop
+byte_offset       -hangul_input      +num64             +timers
+channel           +iconv             +packages          +title
+cindent           +insert_expand     +path_extra        -toolbar
-clientserver      +job               +perl              +user_commands
+clipboard         +jumplist          +persistent_undo   +vartabs
+cmdline_compl     +keymap            +postscript        +vertsplit
+cmdline_hist      +lambda            +printer           +virtualedit
+cmdline_info      +langmap           +profile           +visual
+comments          +libcall           -python            +visualextra
+conceal           +linebreak         +python3           +viminfo
+cryptv            +lispindent        +quickfix          +vreplace
+cscope            +listcmds          +reltime           +wildignore
+cursorbind        +localmap          +rightleft         +wildmenu
+cursorshape       +lua               +ruby              +windows
+dialog_con        +menu              +scrollbind        +writebackup
+diff              +mksession         +signs             -X11
+digraphs          +modify_fname      +smartindent       -xfontset
-dnd               +mouse             +startuptime       -xim
-ebcdic            -mouseshape        +statusline        -xpm
+emacs_tags        +mouse_dec         -sun_workshop      -xsmp
+eval              -mouse_gpm         +syntax            -xterm_clipboard
+ex_extra          -mouse_jsbterm     +tag_binary        -xterm_save
   system vimrc file: "$VIM/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/local/share/vim"
Compilation: clang -c -I. -Iproto -DHAVE_CONFIG_H   -DMACOS_X -DMACOS_X_DARWIN  -g -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1       
Linking: clang   -L. -fstack-protector-strong -L/usr/local/lib -L/usr/local/opt/libyaml/lib -L/usr/local/opt/openssl/lib -L/usr/local/opt/readline/lib  -L/usr/local/lib -o vim        -lncurses -liconv -lintl -framework AppKit  -L/usr/local/opt/lua/lib -llua5.3 -mmacosx-version-min=10.13 -fstack-protector-strong -L/usr/local/lib  -L/usr/local/Cellar/perl/5.28.1/lib/perl5/5.28.1/darwin-thread-multi-2level/CORE -lperl -lm -lutil -lc  -L/usr/local/opt/python/Frameworks/Python.framework/Versions/3.7/lib/python3.7/config-3.7m-darwin -lpython3.7m -framework CoreFoundation  -lruby.2.6

After I mapped some key to Escape key like :inoremap qq <Esc>, when I pressed qq, text <Esc> input, instead of quiting insert mode.

Also, when I followed the guide of :help keycodes, pressing Ctrl+K to complete keycode while setting the key map, nothing happened if I pressed Escape key (however worked for backspace, turned into <BS>).

  • I can't reproduce your test case behavior. Ensure that the problem persists with vim -u NORC
    – klaus
    Mar 5 '19 at 3:54
  • @klaus tried vim -u NORC, same result.
    – chrisyue
    Mar 5 '19 at 6:29
  • I have no idea what is going on. I think you could try another terminal emulator, then a previous version of vim, just to see if the problem persists. I can't help you, but I am on Linux, so it might be a problem with Mac specifically. File a bug report maybe?
    – klaus
    Mar 5 '19 at 6:35

OK, it turns out to be the default option compatible of my homebrew installed vim is compatible, and somehow this option has impact with this <Esc> thing.

It's working well when nocompatible is set

  • It's way past time with this compatible rubbish to be removed from vim. Anyway, glad you could fix it!
    – klaus
    Mar 5 '19 at 6:37
  • 1
    @klaus :shakehands:
    – chrisyue
    Mar 5 '19 at 6:37
  • 2
    As soon as you create a $HOME/.vimrc or $HOME/.vim/vimrc, Vim will automatically switch to nocompatible. See :help 'compatible'.
    – Ralf
    Mar 5 '19 at 8:16

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.