vim 中特定于键的 timeoutlen
是否可以根据键入的键设置不同的超时时间?例如,我的 <Esc>
重新映射到 jk
或 jj
Is it possible to set different timeoutlen depending on typed key?
For example, I have short timeout to go with my <Esc>
remapping to jk
or jj
set timeoutlen=200
但是如果我以 <leader>
开头,我希望这个 timeoutlen 更长,因为我有一些需要按下按键序列的映射,这不是那么容易输入作为 jk
.
but if I start with a <leader>
, I'd like to have this timeoutlen longer, because I have some mappings that require pressing sequence of keys, which are not that easy to type as jk
.
没有任何内置的东西.关于您的映射,您可能指的是 :inoremap jj
,为了快速应用它,您只需要确保没有其他以 开头的插入模式映射 jj
.为避免第一个 j
出现延迟,您可以使用 :autocmds
来切换 'timeoutlen'
值:
There's nothing built-in. With regards to your mapping, you probably mean :inoremap jj <Esc>
, and for that to apply quickly, you just need to ensure that there are no other insert mode mappings that start with jj
. To avoid that the first j
appears only with a delay, you could use :autocmds
to toggle the 'timeoutlen'
value:
:autocmd InsertEnter * set timeoutlen=200
:autocmd InsertLeave * set timeoutlen=1000