I have a mapping to remove trailing whitespace, defined like this: nnoremap <silent> <F6> :%s/\s\+$//<CR>''
. It works fine, except that if I press Esc before pressing F6, instead of doing what it should it seems to do ~(switch case for character) for a bunch of characters where the cursor is placed.
How can I prevent that from happening?
EDIT 1:
I'm on Arch Linux latest updates as of 2017-04-28 with Vim 8.0, running in gnome-terminal. It's the same on all systems I've tested, but it's worth noting that I'm on a Swedish keyboard layout (EDIT: Just tested, and it's the same on en_US layout for me).
EDIT 2:
I've narrowed it down some. While F1–F4 are caught by my terminal (so can't say anything there), F5 produces 5 characters to switch case, F6 produces 7 characters to switch, F7 does 8 and F8 does 9. I've tried disabling my .vimrc
, and that fixes the problem. I'll search through the config and report back when I find what caused it.
EDIT 3:
If I remove my .vimrc, Vi does it but Vim does not. What does that mean?
EDIT 4, major finding:
So I've found the line in my config that causes it. It's noremap <Esc><Esc> :noh<CR>
. Still don't understand why, though. :/