如何让Vim更快地识别ESC键?

时间:2012-10-22 23:01:38

标签: vim

我几乎只在控制台中使用Vim。当我按<ESC>退出插入模式时,Vim识别命令时会有明显的延迟。滞后类似于我按<leader>键时的延迟,我假设给我时间在映射中输入其他字符。我可以设置一个选项让Vim更快地识别转义键吗?

6 个答案:

答案 0 :(得分:24)

如果您使用tmux,可能会引入延迟。把它放在〜/ .tmux.conf文件中:

set -s escape-time 0

答案 1 :(得分:4)

https://stackoverflow.com/a/10856095/157237开始复制:

  

您可能想要检查:help 'timeout'并调整设置   因此。如果需要,您可以将timeoutlen设置为较短的持续时间   (ttimeoutlen默认情况下设置为-1,因此不会使用它。

答案 2 :(得分:2)

当您退出插入模式时,可能会执行一些缓慢的操作。

您可以通过CTRL-C或使用:au InsertLeave保留插入模式来检查。


编辑:

您还可以检查是否有任何映射或缩写等待:iab:imap完成。

答案 3 :(得分:0)

set noesckeys

帮助键:

'esckeys' 'ek'      boolean (Vim default: on, Vi default: off)
                    global
                    {not in Vi}

    Function keys that start with an <Esc> are recognized in Insert
    mode.  When this option is off, the cursor and function keys cannot be
    used in Insert mode if they start with an <Esc>.  The advantage of
    this is that the single <Esc> is recognized immediately, instead of
    after one second.  Instead of resetting this option, you might want to
    try changing the values for 'timeoutlen' and 'ttimeoutlen'.  Note that
    when 'esckeys' is off, you can still map anything, but the cursor keys
    won't work by default.
    NOTE: This option is set to the Vi default value when 'compatible' is
    set and to the Vim default value when 'compatible' is reset.

答案 4 :(得分:0)

可能是您正在发生的事情-它是对我显示这些症状的原因。

map按下 Alt 键以能够使用 Meta 组合键(在 Mate-Terminal Debian上的> Konsole ),我注意到了同一件事-退出插入模式需要timeoutlen。即使使用短短的timeoutlen,这还是令人无法接受的,但是使用nmap会立即导致:)

" Using `map` delays getting out of insert mode by timeoutlen!
for i in range(97,122)
    let c = nr2char(i)
    "exec "map \e".c." <M-".c.">"
    "exec "map! \e".c." <M-".c.">"
    exec "nmap \e".c." <M-".c.">"
endfor

答案 5 :(得分:0)

我在此页面上找不到有效的答案。我在 iTerm2 中使用 vi 键绑定来快速编辑更大的命令。在进入 vi 命令模式之前按下 esc 会增加延迟。您可以通过将以下属性添加到 z-shell 运行配置来关闭延迟:~/.zshrc

KEYTIMEOUT=1
相关问题