In .vimrc:
inoremap jj <Esc>
Given a file containing:
foo
bar
With the cursor at f in normal mode, hit AEsc. Cursor is now at o.
With the cursor at f in normal mode, hit Ajj. Cursor is now down a line at b.
- Why?
- How can I prevent this behaviour (ie make jj work identically to Esc)?
Even though I’ve been using Vim for several years, this one caught me off-guard. After paring down the entire .vimrc to the single line containing the remap, I was still seeing the behaviour described in the question. Creating a brand new .vimrc and typing that binding anew removed the problem.
In the end I realised I’d bound jj to EscSpace by leaving trailing whitespace behind. It must have crept in during a recent revamping of my rc files. Space pressed at the end of line progresses to the next line.
Leaving evidence of my boneheadedness in case it saves someone a few hours someday.