7

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?

4
  • Specificly, something like "keyboard shortcuts reference" in VSCode Commented Sep 25, 2022 at 2: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 ? Commented Sep 25, 2022 at 6: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 Commented Sep 25, 2022 at 6: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. Commented Oct 28, 2022 at 12:07

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

4 Comments

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.
I learned to not worry about unknowns.
Thank you! The way you handle unknowns is illuminating, and the way to find pre-defined commands is detailed.
"... if they are unknown, then they are not used, therefore they are irrelevant." This is assumptive, presumptuous and borderline harmful. How do you think people learn, discover, and grow? Learning, by definition, is someone not knowing, but WANTING to know. The difference is intent. A user may not know that zz exists or what it does, but if they did, they would probably use it. We shouldn't ignore and dismiss the magic of curiosity and discovery.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.