My vim jump to the next word is pretty slow, what am I doing wrong?

In my .vimrc file, I have the following mappings:

nnoremap \ * nnoremap \| # 

for the commands "go to the next word" and "go to the last word".

For some reason, my โ€œgo to next wordโ€ command is slow, about 1 second, before the command seems to be complete, while the โ€œgo to last wordโ€ shortcut is fine (no noticeable delay), I tried to match different keys with this command, and only in some cases there is such a delay.

Does anyone know the reason for this behavior?

+4
source share
3 answers

Since vim waiting for more key after entering \

You can change the timeout (default is 1 second):

 :set timeout timeoutlen=100 ttimeoutlen=100 

(time after display after 0.1 seconds, waiting time for key codes after 0.1 seconds).

+4
source

If you intended to match a backslash with the first command, I would suggest putting something like

 let mapleader='_' let maplocalleader='_' 

into your vimrc (replace the underscore with any sequence of characters that {lhs} you), because many plugins create mappings whose {lhs} begins with <Leader> , and therefore vim expects the next key to determine if it was a plugin mappings as @kev correctly pointed out. If you put the above lines in vimrc, those plugins that use *map <Leader>... will now create mappings starting with an underscore, instead of starting them with a backslash. If this does not help, check the verbose map \ and read the plugins documentation to determine if there is an official way to get them to generate a map with another leader.

0
source

I had a similar problem, but not related to mapleader. It turned out that there were some other commands that used my "go to the next word" key as a prefix (in my case it was y ). Here is what I did:

  • Error :nmap to list all mappings.
  • Mark those that start with the "go to next word" key. In my case, it was yo and yo .
  • Cancel these commands in .vimrc . In my case, it was unmap yo and unmap yo .
  • Reload .vimrc with :so $MYVIMRC for the change to take effect.
0
source

Source: https://habr.com/ru/post/1401623/


All Articles