jeffkreeftmeijer / vim-numbertoggle

Toggles between hybrid and absolute line numbers automatically
https://jeffkreeftmeijer.com/vim-number/#automatic-toggling-between-line-number-modes
MIT License
682 stars 49 forks source link

Delay changing line numbers after exiting Insert Mode #54

Open superjamie opened 1 year ago

superjamie commented 1 year ago

tl;dr - This isn't your fault, and I come bearing multiple solutions.

After hitting Esc to exit Insert Mode, my Vim/Neovim would wait a second or so before setting line numbers back to relative. This was really annoying and broke the workflow of quick responsive changes.

After a lot of debugging, I found this was caused by another binding I had which started with <Esc>. Vim was waiting for the timeoutlen to see if I'd hit anything else after I hit the Esc key. I didn't more keys so then it ran the mode change which fires with this plugin, hence the delay in changing line numbers.

Users can find keymaps like this with:

:verbose imap <Esc>

Reference: https://github.com/vim/vim/issues/1498#issuecomment-281206147

The solution for me was to just remove the other <Esc> mapping, I'll pick another key combination for what I had.

Another solution is probably to reduce the timeoutlen to say 50ms like this, though it might make other keybinds harder to hit:

set timeoutlen=50

If you're interested in adding an FAQ section to the readme with things like this, I'm happy to send a PR to save you the effort? There are one or two other things here in Issues over the years which could be in such an FAQ too.

Otherwise, feel free to close this Issue. Discussions aren't enabled on this repo so I didn't see anywhere else to post.

Also, many thanks for your excellent plugin! You've made my Vim experience a lot better. This and hardtime really got me using vertical line motions properly.

superjamie commented 1 year ago

Ha, spoke too soon, I also needed to add set -sg escape-time 1 to ~/.tmux.conf for it to work in tmux! The tmux default is 500ms.