检测某个键是否绑定到 vim 中的某个东西
我想知道是否有办法确定 vim 中某个键是否执行某些操作。我知道我可以使用 :map
来查看用户定义的映射,但是有内置的东西吗?
例如,我总是将 CTRL-W 绑定到关闭选项卡,因为我认为它没有被使用。半年后,我发现有一些序列使用了它,例如 CTRL-W CTRL-S 来分割窗口,重新训练自己是一场噩梦。
I'd like to know if there is a way to figure out if a key does something in vim. I know that I can use :map
to see user-defined mappings, but is there something for the built-in stuff?
For example, I always had CTRL-W bound to close tab, because I thought that it was unused. After half a year, I found out that there are some sequences that use it, like CTRL-W CTRL-S to split the window, and it was a nightmare to retrain myself.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
如果您查看兰迪·莫里斯的建议答案,您会发现它
会给您所需的列表。
If you check out the suggested answer by Randy Morris you will find that
will give you the list you want.
要检查默认映射:
对于由用户或插件完成的其他映射:
来自 http://vim .wikia.com/wiki/Mapping_keys_in_Vim_-教程(Part_1):
To check the default mapping:
For other mapping that is done by either users or plugin:
From http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-Tutorial(Part_1):
这不是一个完整的答案,但您可能需要查看
:help map-which-keys
以获得 vim 建议您在自定义地图中使用的键列表。该帮助部分提供了如何判断特定键是否映射到操作的建议。
Not a complete answer, but you may want to check out
:help map-which-keys
for a list of keys that vim recommends you to use in your custom maps.That help section has a recommendation of how to tell if a specific key is mapped to an action.
我浏览了
:help index
并列出了一些未使用的nmap
键:
(与普通模式下的l
相同;普通模式下最大且最未被充分利用的键)请更新/评论。
I skimmed through
:help index
and made a list of some of the unusednmap
keys:<Space>
(same asl
in the normal mode; the largest and the most underutilized key in the normal mode)Please update/comment.
使用
:map!
和:map
手动设置键,使用:help 'char(-combination)'
找出哪些键已经映射在 vim 中开箱即用(/超出您的特定编译选项)。(有点偏离主题,但仍然值得关注(我认为):使用
:scriptnames
来查看哪些文件是按什么顺序获取的。)Use
:map!
and:map
for manually set keys and:help 'char(-combination)'
to find out which keys are already mapped in vim out-of-the-box(/out of your specific compiling options).(Slightly off-topic but still regardable (I think): Use
:scriptnames
to see which files have been sourced in which order.)您可以使用
mapcheck
.:-例如,我想映射是否已存在映射: , i
; ,i
到gg=G
来缩进文件。要检查
...但这不会检测映射是否是序列的一部分。
You can use
mapcheck
.:-For example, I wanted to map
<CR> ,i
togg=G
to indented a file.To check if there is a mapping already for
<CR> , i
...but this won't detect if the mapping is part of a sequence.
仅为了完成这篇非常古老的文章,以下内容将打印是否设置了特定的键绑定以及由什么源设置。如果映射发生冲突/重叠,
verbose
关键字将为您提供设置绑定的源的列表。例如,对于
... 在正常模式下:Only to complete this very old post, the following will print if and by what source a specific keybinding was set. In the event the mappings collided/overlapped, the
verbose
keyword will provide you the list of which sources set the binding. e.g., for<C-n>
... in normal mode: