Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to figure out key map redefined in vim plugin?

Tags:

vim

I installed many plugins by vundle. I found there maybe multiple plugins use the same hotkey. Is there smart way to figure out which plugin contains such hotkey?

There are some tutorial about key map. But I still haven't any idea.

like image 1000
Daniel YC Lin Avatar asked Nov 01 '25 10:11

Daniel YC Lin


2 Answers

A warning

Don't just install many plugins; you'll end up with a complex, slow, and indecipherable mess over time. Especially with plugin managers like Vundle, it's very easy to check out plugins. That benefit can turn bad if you forget to remove plugins that don't turn out to be useful for you.

How to check

In general, the plugin should advertise its features and defaults mappings (and hopefully provides configuration to change those!)

If you indeed have overlapping mappings, you should check:

  1. The plugin's documentation.
  2. The plugin's source code; look for :*[nore]map commands in the plugin/pluginname.vim script.
  3. The actual existing mappings; the :map command lists those. You can restrict the command by modes (e.g. :imap for insert mode mappings) and starting keys (e.g. :map <Leader> lists all mappings that begin with the (configurable) Leader key).

How to change mappings

The canonical way to change plugin mappings is by defining your own mapping to <Plug>... targets that the plugin provides, e.g. :nmap <F1> <Plug>PluginNameMapping, in your ~/.vimrc. Some plugins also use global variables; refrain from modifying the plugin script itself; rather, complain to its author!

like image 123
Ingo Karkat Avatar answered Nov 03 '25 04:11

Ingo Karkat


Yes, there is.

Use :verbose map <YOURKEY>. It will show you which file was the latest to modify this mapping.

like image 41
ranys Avatar answered Nov 03 '25 04:11

ranys



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!