Skip to content

fix: visual mode delay on y#342

Open
hernancerm wants to merge 1 commit intojeffreytse:masterfrom
hernancerm:fix-vis-mode-delay-on-y
Open

fix: visual mode delay on y#342
hernancerm wants to merge 1 commit intojeffreytse:masterfrom
hernancerm:fix-vis-mode-delay-on-y

Conversation

@hernancerm
Copy link
Copy Markdown

@hernancerm hernancerm commented Apr 18, 2026

Problem

When ZVM_VI_SURROUND_BINDKEY=classic (default) and in visual mode, y has a delay of ZVM_KEYTIMEOUT before it yanks. In the video I set the timeout to 1.4 seconds to make the delay easier to notice. In my experience, this delay is noticeable during the actual usage of the plugin even when the timeout has the default value of 0.4 seconds.

vis-mode-delay-on-y.mp4

Solution

Remove the visual mode classic-mode-surround keybind ys<surround>.

The visual mode ys<surround> keybind causes the delay since there are two visual mode keybinds that start with y: y itself and ys<surround>. By removing the latter then y can be resolved immediately. I've reviewed vim-surround and there is no ys<surround> visual mode keymap, so I think that removing this keybind is sensible (although it can be considered a breaking change). No change when ZVM_VI_SURROUND_BINDKEY=s-prefix. Behavior from this branch:

vis-mode-delay-on-y-fixed.mp4

Notes

The videos were recorded using vhs (from this PR) with this tape file so the inputs are exactly the same on both tests:

vis-mode-delay-on-y.tape
Output vis-mode-delay-on-y.mp4

Set TypingSpeed 0.5s
Set CaptionFontSize 26
Set CaptionInactivityTimer 500ms
Set CaptionAlignment "bottom-left"
Set CaptionKeyStyle "vim"
Set Width 840
Set Height 300
Set Shell zsh

Hide
Type@5ms "curl -L raw.githubusercontent.com/jeffreytse/zsh-vi-mode/refs/heads/master/zsh-vi-mode.zsh | source /dev/stdin && clear"
#Type@5ms "curl -L raw.githubusercontent.com/hernancerm/zsh-vi-mode/refs/heads/fix-vis-mode-delay-on-y/zsh-vi-mode.zsh | source /dev/stdin && clear"
Enter
Sleep 0.2s
Show

CaptionOn

Type@0.1s "ZVM_KEYTIMEOUT=1.4"
Enter

Sleep 0.5s
Type@0.2s "foo"
Ctrl+[
Sleep 0.5s
Type "vb"
Sleep 1s
Type "y"
Sleep 2s

Thanks for the plugin!

Problem:  In visual mode, `y` should yank the selected text without delay.
          A visual mode classic-surround keybind, ys<surround>, causes a
          delay on yanking in visual mode due to the common `y` prefix
          shared between yank and this surround action.

Solution: Remove the visual mode classic-surround keybind `ys`, since this
          is not a visual mode surround keybind in tpope/vim-surround.
@hernancerm hernancerm changed the title fix: vis mode delay on y fix: visual mode delay on y Apr 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant