禁用esc键上的超时 [英] Disable timeout on esc key

查看:132
本文介绍了禁用esc键上的超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在insert mode中,然后我可能会键入一个数字,然后迅速键入 ESC ,因为我停止了键入,因此它将更改为visual mode. 然后发生的是cursor跳转,不仅如此,我(以及我刚刚键入的)行上的数字减少了. 这件事是一场噩梦!

I am in insert mode, and then I might type a number, and then quickly ESC, because I stopped typing so it will change to visual mode. What happens then, is that the cursor jumps, and not only that, the number on the line that I was (and I just typed) is decremented. This thing is a nightmare!

这是某种默认行为吗?如果是这样,如何禁用它? 可能是引起它的插件吗?因为我并不总是具有这种功能". 我试了几个月才弄清楚是什么原因,并且我已经发布了这个

Is this some kind of default behavior? If so, how can I disable it? Could this be a plugin causing it? Because I didn't always had this "feature". I was trying for some months to figure out what is causing this, and I've posted this generic question.

尤其是在编程时,数字自动递减会引起很多麻烦,因此我通过在我的.vimrc中映射<C-a> <Nop>禁用了默认映射.更多信息此处.

Especially when programming, number auto-decrement can cause lot of headaches, so I've disabled the default mapping for it, by mapping <C-a> <Nop> in my .vimrc; more info here.

推荐答案

您的问题似乎与'timeout'选项及其朋友'timeoutlen''ttimeout''ttimeoutlen'相关.

Your issue seems linked to the 'timeout' option, and its friends 'timeoutlen', 'ttimeout', 'ttimeoutlen'.

尝试以下命令:

:set timeout timeoutlen=3000 ttimeoutlen=100

它取自:h 'ttm:

仅当'timeout'和'ttimeout'选项出现时才发生超时 说出来.一个有用的设置是:set timeout timeoutlen = 3000 ttimeoutlen = 100(三秒钟后映射超时,超时 在十分之一秒后输入关键代码).

The timeout only happens when the 'timeout' and 'ttimeout' options tell so. A useful setting would be :set timeout timeoutlen=3000 ttimeoutlen=100 (time out on mapping after three seconds, time out on key codes after a tenth of a second).


我个人使用以下设置:


Personally, I use these settings:

set timeout
set ttimeout
set timeoutlen=3000
set ttimeoutlen=50

前2个命令分别对映射和键码启用超时.

The first 2 commands enable a timeout on mappings and keycodes respectively.

第三个命令set timeoutlen=3000告诉Vim等待3s让我完成映射左侧的输入.

The 3rd command set timeoutlen=3000 tells Vim to wait 3s to let me finish typing the left-hand-side of a mapping.

第四个命令set ttimeoutlen=50告诉Vim仅等待50ms一系列键码完成.例如,在我的机器上,F1生成键码序列Escape O P(通过在插入模式下键入C-v F1确认,显示^[OP^[代表Escape).

The 4th command set ttimeoutlen=50 tells Vim to only wait 50ms for a sequence of keycodes to finish. For example, on my machine, F1 produces the sequence of keycodes Escape O P (confirmed by typing C-v F1 in insert mode, which displays ^[OP; ^[ stands for Escape).

您的原始问题很可能是由于'ttimeoutlen'选项的值太高而导致的,因此按键序列的超时没有足够快地发生,这使得Vim有时会解释您键入的击键是由您未按的其他键产生的.通过降低其值,您可以防止这种情况.

It's possible that your original issue comes from the fact that the value of your 'ttimeoutlen' option is too high, and therefore the timeout for a sequence of keycodes doesn't occur soon enough, allowing Vim to sometimes interpret a sequence of keystrokes you type as produced by some other key you didn't press. By reducing its value, you may prevent this.

即使您在vimrc中设置了先前的选项,如果问题仍然存在,则可能是插件之后对其进行了更改.

If your issue persists even though you set the previous options in your vimrc, it's possible that a plugin changes them afterwards.

在这种情况下,当您的问题再次出现时,请键入以下命令:

In this case, when your issue occurs again, type these commands:

:verb set timeout?
:verb set ttimeout?
:verb set timeoutlen?
:verb set ttimeoutlen?

每个选项都可以告诉您选项的当前值,但更重要的是,它可以告诉您更改该值的最后一个文件的名称.

Each of them will tell you the current value of your options, but more importantly it will tell you the name of the last file which changed the value.

这篇关于禁用esc键上的超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆