4

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?

longguzzz
  • 43
  • 4
  • Specificly, something like "keyboard shortcuts reference" in VSCode – longguzzz Sep 25 '22 at 02:10
  • 1
    I think there can be a misunderstanding. For most part, it contains an action key and a movement key to consist of a command. For example, dw dG viw zz zb zt . I think you can list action keys and movement keys separately, and there are some key binding that probably not in both aspects and those are the ones you referring in the question ? – Hi computer Sep 25 '22 at 06:22
  • 1
    Since you can input dw d2w d3w, 2j 3j 4j things like that, I would say there is infinite commands and you can’t list them all – Hi computer Sep 25 '22 at 06:29
  • 1
    Thank you, your comment help me realize the subtle difference between those concepts. The thing I am finding here is something like pre-defined atom operation. But I can not describe it more percisely due to my lack of vim knowledge. I think I need to read the whole manual in some day and the whole view of vim will be clear. – longguzzz Oct 28 '22 at 12:07

1 Answers1

4

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.

romainl
  • 186,200
  • 21
  • 280
  • 313
  • Although an argument could be made that trying to choose a key combination that isn't an existing command, even one you don't currently use (say, `zz`), is preferable because if you later want to start using the original `zz` command this means you now have to remap your custom command, and relearn that new key choice. In general I try not to trample over Vim's existing keybindings if I can help it. – mattb Sep 25 '22 at 07:56
  • 1
    I learned to not worry about unknowns. – romainl Sep 25 '22 at 09:49
  • Thank you! The way you handle unknowns is illuminating, and the way to find pre-defined commands is detailed. – longguzzz Oct 28 '22 at 12:11