Search code examples
vimkeymaps

In NeoVim/Vim, how to know all used key combination?


I want to set my own keybinding, but I can not sure what key combination has been used by other plugins or neovim/vim itself. :map does not show shortcuts like zz. If I don't know zz before, my map setting may use it and cover the orginal function. However, I can not sure how many unknown used key combination exsist in different situations.

Is there any command to show all of them in a list? Or if I want to set some key combination, is there any method to check all the situation that it has been used?


Solution

  • You can…

    • get a list of all active mappings with :help maplist(),
    • get details about a specific mapping with :help maparg(),
    • check if a mapping exists with :help mapcheck(),
    • check if a mapping to a specific command exists with :help has_mapto().

    But I'm afraid there are some misconceptions, here: things like zz are not "shortcuts" or "mappings". They are commands and, as such, will never come up with the functions above.

    If you want a list of all normal mode commands, see :help normal-index.

    That said…

    If I don't know zz before, my map setting may use it and cover the orginal function.

    Well, you didn't know zz, therefore you didn't use it, therefore you wouldn't notice that it was overridden, therefore you could override it with zero downside.

    However, I can not sure how many unknown used key combination exsist in different situations.

    As above, if they are unknown, then they are not used, therefore they are irrelevant.