简体   繁体   English

为什么Vim延迟这个重映射的密钥? 我该如何解决?

[英]Why does Vim delay on this remapped key? And how do I fix it?

I have the following lines in my vimrc: 我的vimrc中有以下几行:

noremap gb vnoremap gb

The goal of these is pretty clear: move one word to the left whenever I press g. 这些的目标非常明确:每当我按下g时,向左移动一个单词。

My issue is that there is a delay of about 1/2 second before vim executes the move. 我的问题是在vim执行移动之前有大约1/2秒的延迟。 It is as if vim is waiting for me to enter an addition command. 好像vim正在等我输入一个加法命令。

I know vim does this kind of thing when it is expecting more information. 我知道vim在期待更多信息时会做这种事情。 However, this is the only case where I have a remap that involves g, so it's unlikely to be the case. 但是,这是我唯一一个涉及g的重映射的情况,因此不太可能出现这种情况。

Other people seem to be having similar problems: Eliminating lag when remapping 'd' key in VIM 其他人似乎也有类似的问题: 在VIM中重新映射'd'键时消除了延迟

But no one has yet offered a solution. 但还没有人提供解决方案。

Any thoughts? 有什么想法吗?

If I do this and start vim using vim -u NONE -N I can't replicate the behaviour. 如果我这样做并使用vim -u NONE -N启动vim,我无法复制该行为。 Looking further, this seems to be caused by the netrw plugin, which maps the gx key as well as the matchit plugin, that maps g% . 进一步看,这似乎是由netrw插件引起的,它映射了gx键以及映射g%的matchit插件。 (You might to check using :verbose :map g to see, if there are other ambigious g mappings that could cause this and where they were defined (by the use of :verbose )). (您可以使用:verbose :map g来查看,如果存在其他可能导致此问题以及它们被定义的地方(通过使用:verbose ),则可以:verbose

So to prevent this, you should unmap those mappings and then the g works without delay. 因此,为了防止这种情况,您应该取消映射这些映射,然后g工作无延迟。 But as progo already said, you lose all those nice builtin g<x> commands, so I would not recommend to map g away 但正如progo已经说过的那样,你失去了所有那些漂亮的内置g<x>命令,因此我不建议将g映射掉

Note also, recent vims have the <nowait> modifier, so you can just do noremap <nowait> gb and no delay will occur. 另请注意,最近的vims具有<nowait>修饰符,因此您可以执行noremap <nowait> gb并且不会发生延迟。

But vim is expecting more information. 但VIM 期待更多的信息。 There is a bunch of normal mode key bindings that start with g such as ( gg , gd , gf , gq , ...) and of course vim has to wait until it knows what you started to type in. 有一堆普通模式键绑定以g开头,例如( gggdgfgq ,...),当然vim必须等到它知道你开始输入的内容。

This is a situation you can't really fix without breaking lots of other mappings. 这是一种在不破坏大量其他映射的情况下无法真正解决的情况。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 为什么当我使用重新映射的密钥访问插件命令时,vim为什么说“未连接” - Why does vim say “Not Connected” when I use a remapped key to access a plugin command 如何重复以 VIM 中的前导键开头的重新映射命令? - How to repeat a remapped command thats starts with a leader key in VIM? Vim不接受“领导者”键-超时设置,重新映射为“,”,但仅发出哔声 - Vim does not accept Leader key - timeout set, remapped to “,”, but yet only beeps 如何在vim-airline的操作员挂起模式下显示重新映射的密钥而不是原始密钥? - How to display remapped key instead of original key in operator-pending mode in vim-airline? Vim:你怎么知道vim中的击键是做什么的? - Vim: How do you know what a key stroke does in vim? 如何在Vim中修复HTML / PHP文件中的缩进? - How do i fix the indents in my html/php files in vim? 在vim shift + w(W)不起作用。 它像w一样前进。 我如何解决它? - in vim shift+w (W) does not work. It moves forward like w. How do I fix it? Vim的高级单词在python中损坏了,我该如何解决? - Vim's advance word broken in python, how do I fix this? 我该如何解决Vim的这个小缩进问题? - How do i fix this minor indent issue with vim? 如何修复Vim中不正确的内联Javascript缩进? - How do I fix incorrect inline Javascript indentation in Vim?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM