DEV Community

Serhat Teker
Serhat Teker

Posted on • Originally published at tech.serhatteker.com on

1

How to Debug Key Mappings in Vim

Sometimes my mapping not working since overridden by plug-in or I forget a mapping and want to select from all my mappings list.

All List

If you want to get all your key mappings run:

:map <key>
Enter fullscreen mode Exit fullscreen mode

Specific Key

If you only want to know specific key(s) run:

:map <key>
Enter fullscreen mode Exit fullscreen mode

Like examples below:

:map <leader>f
:map H
:map <F8>
Enter fullscreen mode Exit fullscreen mode

Verbose Mode - Show Overridden

If you can't use your mapping and want to know what overrides it just run with
verbose:

:verbose map <key>
Enter fullscreen mode Exit fullscreen mode

This will show all configs that uses given mapping in a list and last
set
location:

vim mapping

Also it is possible to use :map with visual, normal, insert etc. as
well:

:vmap rn
:nmap rn
:imap rn
Enter fullscreen mode Exit fullscreen mode

All done!

Top comments (1)

Collapse
 
brandonwallace profile image
brandon_wallace

Nice article Serhat.

The *map command are recursive which can cause issues with plugins that map to the same keys.

Here is an example:

nmap x j        # Your mapping
nnoremap j x    # Plugin mapping
Enter fullscreen mode Exit fullscreen mode

You want x to move the cursor down a line but the plugin maps j to delete one character.
Now when you press x to move down one line you end up deleting a character.

nnoremap x j    # Your mapping
nnoremap j x    # Plugin mapping
Enter fullscreen mode Exit fullscreen mode

Now both mappings work.

It is much better to use nnoremap, inoremap, vnoremap to map your keys.

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, cherished by the supportive DEV Community. Coders of every background are encouraged to bring their perspectives and bolster our collective wisdom.

A sincere “thank you” often brightens someone’s day—share yours in the comments below!

On DEV, the act of sharing knowledge eases our journey and forges stronger community ties. Found value in this? A quick thank-you to the author can make a world of difference.

Okay