1

I put this line in my .vimrc so that I could press escape to exit vim while in normal mode:

:nnoremap <Esc> :q<CR>

But now $ vim causes vim to flash up briefly and then exit every time. Same with $ vim filename.

Removing the line restores normal behaviour. Is there any way to get this functionality? I am pretty sure that I had it working before but can't think why it would have broken between then and now.

Gus Hogg-Blake
  • 2,393
  • 2
  • 21
  • 31
  • I can't replicate your issue, have you added anything else that could be related in your vimrc. Do you have your .vimrc on github so we can look at it? – Ace Apr 18 '15 at 20:26
  • 2
    I can reproduce this with `vim -u ex.vim -N` where `cat ex.vim` is `:nnoremap :q`. Can't when I have additional line `nnoremap :nohlsearch`, or start vim with GVim. My vague guess is that the terminal sends escape sequence of some kind on startup. Possibly related to [vi - Vim has unexpected key presses on startup, what could be causing this? - Super User](http://superuser.com/questions/553601/). – Yosh Apr 19 '15 at 06:50

2 Answers2

2

Vim can end up with some very strange behaviour when remapping <Esc>. I'd recommend using a different key for this if you don't want a headache.

See this question for reference: Mapping <esc> in vimrc causes bizzare arrow behaviour

Community
  • 1
  • 1
Chris Penner
  • 1,881
  • 11
  • 15
0

Adding :set t_RV= ttymouse=xterm2 to .vimrc fixes the issue (see https://superuser.com/questions/553601/).

Community
  • 1
  • 1
Gus Hogg-Blake
  • 2,393
  • 2
  • 21
  • 31