In vim --clean
, I insert these lines:
One
Two
Three
Four
Five
Six
Then I do:
:set mouse=a
:nnoremap <Esc><Esc> <Nop>
(From my observations, the mapping could be to anything. :nnoremap <Esc><Esc> :echom "Hello"<CR>
would work just as well for this demonstration).
- I position the cursor on the first column of the first line.
- Then, I input (but not Enter) something in the command line area (e.g.
:blabla
). - At this point, I press EscEsc, and I use my mouse to click on
Six
(the last line in the buffer).
Surprise: the cursor is positioned on the third line (Three
)! What could be the reason for such a strange behavior?
Even more intriguing, doing :nnoremap ; :
and repeating the steps above does not move the cursor at all! Instead, something like :2;6M
would be displayed in the echo area. It seems that the format of the echoed message is: colon, followed by the column number of the mouse click, semicolon, followed by the line number of the mouse click, then an uppercase letter M.
<ESC>
is issued in command mode and interpreted as normal. Your second<ESC>
can be the start of your mapping. Depending on your terminal mouse clicks might be (I don't know for sure) represented as a character sequence starting withESC
. In that case the leadingESC
would trigger your mapping and the remainder of that sequence would be interpreted as normal mode commands.ESC
, they're mapping two presses ofESC
, which shouldn't conflict with terminal escape sequences. I think Jürgen Krämer has got this one right.