:verbose map
does not work for detecting the keybind in insert mode. Since it's while editing, and the relevant mapping is imap
or inoremap
, :verbose imap
/:verbose map!
are the two correct options to use for tracking down the conflict.
In this case, the reason I had such weird behavior is because of the function it's mapped to. It calls a function in a parentheses auto-completion/utility plugin, and specifically a fast wrap feature.
However, independently of that plugin, a meta keybind conflicting with a letter does indeed cause unexpected behavior. What that behavior is depends on the mapping used. Whether it's from a plugin or something you set yourself, is something you'll have to figure out.
In general
Some meta keybinds map to non-ascii/European/other letters. In insert mode, this means the corresponding letters become an alternate way to use the meta keybind. This boils down to how input processing in Vim works, and that's a convoluted mess I don't understand myself, so I won't comment too much on it.
Use :verbose imap å
(replace å
with your affected letter) to determine which keybind is affected.
As an example, å
is equivalent to <M-e>
on my system. <M-e>
may correspond to something else on your system, however, because input processing is weird.
When you determine which keybind is affected with :verbose imap
, you'll be able to track down the source. verbose imap
includes a path to the affected file, as well as the line it's declared on.
Taking a look at the output I had:
:verbose imap å
i å *@<C-R>=AutoPairsFastWrap()<CR>
Last set from ~\.vim\plugged\auto-pairs\plugin\auto-pairs.vim line 562
The second line is the part that's guaranteed to give you enough information. Reading the relevant information is trivial, and explicitly a part of the output.
If your keybinding is set from a:
- a
.vimrc
or other config file you've written, edit the keybind to something else.
- a plugin, read the documentation and/or plugin code. Some plugins have variables for re-mapping or fully unmapping keys. If no such option exists, find the bug tracker for the plugin and post there. As a hack, you can always edit the file in the meanwhile, but this may cause conflicts if you use a plugin manager with semi-automatic updates.
When you've fixed it, you of course need to reload Vim, and you should be good to go.
Note: I highly recommend avoiding meta-based keybinds in insert mode entirely, particularly in plugins.
Auto-pairs
In my particular case, jiangmiao/auto-pairs was the source of this problem.
Running :verbose imap å
or :verbose map! å
gave me this:
i å *@<C-R>=AutoPairsFastWrap()<CR>
Last set from ~\.vim\plugged\auto-pairs\plugin\auto-pairs.vim line 562
The block that set the shortcut looks like this:
if g:AutoPairsShortcutFastWrap != ''
execute 'inoremap <buffer> <silent> '.g:AutoPairsShortcutFastWrap.' <C-R>=AutoPairsFastWrap()<CR>'
end
By default, the shortcut is set to <M-e>
, but that in itself doesn't necessarily make sense, especially with the mapping. If, however, you type <M-e>
when it's not remapped, it outputs å
. <C-v> <M-e>
also gives å
this might be keyboard-dependent - I'm not sure and I can't test it. So the plugin remapping <M-e>
resulted in å
being remapped to a function that when provided sensible input works fine, but when provided none or invalid input results in the weird behavior I saw.
The reason I couldn't override it is because the original remapping was done with <buffer>
, which seems to override the global ones. I think that's the reason imap å å
didn't work. With imap <buffer> å å
, it outputs å instead of calling the plugin function that originally defined it.
That being said, there's a relatively easy fix to this that doesn't require any remapping of å
, but rather remapping the plugin. The code I showed earlier uses g:AutoPairsShortcutFastWrap
, which defines which key it'll map to. I just decided on <C-f>
, but any unused shortcut will do:
let g:AutoPairsShortcutFastWrap = "<C-f>"
After reloading Vim, å
works as a normal letter again.
:verbose map
shows the mappings for normal, visual, select, and operator-pending mode. For insert mode mappings you need to use:verbose imap
or:verbose map!
(see:help map-modes
).