Key-specific timeoutlen in vim

前端 未结 2 1594
梦毁少年i
梦毁少年i 2021-01-12 05:38

Is it possible to set different timeoutlen depending on typed key? For example, I have short timeout to go with my remapping to jk or

2条回答
  •  误落风尘
    2021-01-12 06:42

    The solution proposed by Ingo Karkat will affect all insert mode mappings, so it may break plugins that define other insert mode mappings that are hard to type in so short a time period.

    In order to escape from insert mode without lagging, I have found a smarter way, which leads to plugin better-escape.vim.

    The default shortcut to escape insert mode is jk, you can change it via the following option:

    let g:better_escape_shortcut = 'jj'
    

    It will calculate the time interval between pressing the first char and the second char in the shortcut (the default is 150 ms). If you press those two chars quickly, you will leave insert mode. Otherwise, the characters will be written literally. To adjust the time interval, use the following option:

    let g:better_escape_interval = 200
    

提交回复
热议问题