有没有办法检查 neovim/vim 中未映射到任何功能的键组合?

huangapple go评论61阅读模式
英文:

Is there any way to check which key combinations are not mapped to anything in neovim/vim?

问题

偶尔,我会将一组相关的操作(通常与插件相关)映射到一组键组合上。

我尝试使用一些助记符来帮助记忆它。
例如,我为overseer插件添加了3个映射(qr、qt、qa)分别用于(运行、切换和快速操作)。

当我这样做时,我需要首先确定哪些键组合“未被使用”。

问题是是否有一种方法来识别一组“未被使用的键组合”,以便用来映射新的操作集。 (*A) (*B)

*A: 并不是我有太多的使用组合,而是有时现有的组合嵌入在肌肉记忆中,直到看到其定义才意识到它们已被使用。

*B: 理解存在无限的键组合,意图是选择X个最推荐的。

与这个问题相反:https://stackoverflow.com/questions/73841647/in-neovim-vim-how-to-know-all-used-key-combination

英文:

Occasionally, I map a group of related actions (usually related to a plugin) to a group of key combinations.

I try to use some mnemonics to ease remembering it.
For instance, I added 3 mappings for overseer plugin (qr, qt, qa) for (Run, Toggle and Quick Action respectively).

When I do that I need to identify which key combinations "are not used" first.
The question is if there is a way to identify a group of "not used key combinations" that can be used to map a new set of actions. (*A) (*B)

*A: Is not that I have too many use combinations, but sometimes the existing combinations are embedded in muscle memory, and do not realize that are used until seeing its definition

*B: Understanding that there is an infinite key combination, the intention is to the X most recommended.

Kind of the opposite of this question: https://stackoverflow.com/questions/73841647/in-neovim-vim-how-to-know-all-used-key-combination

答案1

得分: 3

以下是翻译好的部分:

好的,你作为示例提到的 qrqtqa 实际上是不可用的,除非你可以接受失去将宏记录到寄存器 rta 的能力。

我已经维护了一份此类可用对的列表一段时间了。


运算符 cdy 需要一个动作,如 we 等。以下对中的第二个字符不是动作,因此它是 NOP,如果在映射中使用它们,将不会覆盖任何内容。

   cd cm co cp cq cr cs cu cx cy cz
dc    dm       dq dr ds du dx dy dz
yc yd ym yo yp yq yr ys yu yx yz

v 不是运算符,但它具有类似的语义。可用对较少,因为可以在 v 之后立即使用运算符。

vm vo vq vv vz

Vi 没有为 g 分配任何内容,因此 Vim 在某种程度上将该命名空间视为新的双字符命令的垃圾桶。以下是剩下的可用对:

gb gc gl gs gy

z 也是空闲的,它受到了相同的对待,结果更糟:

zq

注意:Gist 中的注释也值得阅读。

注意:gs 在列表中是因为 认为它是无用的。你的看法可能不同。

英文:

Well, the one you gave as example are actually not available: qr, qt, qa, unless you are OK with losing the ability to record macros into registers r, t, and a.

I've maintained a list of such available pairs for a while.


The operators c, d, and y expect a motion, like w, e, etc. The second character in the following pairs is not a motion so it is a NOP and nothing is overridden if we use them in mappings.

   cd cm co cp cq cr cs cu cx cy cz
dc    dm       dq dr ds du dx dy dz
yc yd ym yo yp yq yr ys yu yx yz

v is not an operator but it has similar semantics. There are fewer available pairs, though, because it is possible to use an operator right after v.

vm vo vq vv vz

Vi didn't have anything assigned to g so Vim kind of treated the namespace as a dumpster for new two-characters commands. Here are the pairs that are left:

gb gc gl gs gy

z was free, too, and it got the same treatment, with an even worse outcome:

zq

NOTE: The comments in the gist are also worth reading.

NOTE: gs is in the list because I think it is useless. YMMV.

huangapple
  • 本文由 发表于 2023年6月9日 02:13:25
  • 转载请务必保留本文链接:https://go.coder-hub.com/76434640.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定