Vim cursor skips forward on single-letter replace #14731

Closed
opened 2026-01-31 04:17:59 +00:00 by claunia · 4 comments
Owner

Originally created by @LRitzdorf on GitHub (Jul 30, 2021).

Originally assigned to: @DHowett on GitHub.

Windows Terminal version (or Windows build number)

WT v1.9.1942.0; MS Windows v10.0.19043.1110

Other Software

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 2 2021 22:02:47)
64-bit console version for Windows, downloaded from https://github.com/vim/vim-win32-installer/releases/tag/v8.2.2825#:~:text=Signed%2064-bit%20installer. Patch version 2825.

Powerline v2.7 (Python3). powerline-status module, installed via pip.
This is not likely to be related to the issue, but I thought I'd include it nonetheless.

Steps to reproduce

  • Open vim. Of the following, set t_EI and either of the t_S* variables:
let &t_EI .= "\<Esc>[1 q"
let &t_SR .= "\<Esc>[3 q"
let &t_SI .= "\<Esc>[5 q"
  • Trigger single-letter replacement mode by pressing r.
  • The cursor jumps forward, by five characters in my case.

Expected Behavior

The cursor should not jump forward when single-letter replacement mode is triggered.

Actual Behavior

The cursor jumps forward, as noted above.

Note that I've tested this same combination of factors in WSL Vim, and the jump does not occur.

Originally created by @LRitzdorf on GitHub (Jul 30, 2021). Originally assigned to: @DHowett on GitHub. ### Windows Terminal version (or Windows build number) WT v1.9.1942.0; MS Windows v10.0.19043.1110 ### Other Software VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 2 2021 22:02:47) 64-bit console version for Windows, downloaded from https://github.com/vim/vim-win32-installer/releases/tag/v8.2.2825#:~:text=Signed%2064-bit%20installer. Patch version 2825. Powerline v2.7 (Python3). `powerline-status` module, installed via `pip`. This is not likely to be related to the issue, but I thought I'd include it nonetheless. ### Steps to reproduce - Open vim. Of the following, set `t_EI` and either of the `t_S*` variables: ```vim let &t_EI .= "\<Esc>[1 q" let &t_SR .= "\<Esc>[3 q" let &t_SI .= "\<Esc>[5 q" ``` - Trigger single-letter replacement mode by pressing `r`. - The cursor jumps forward, by five characters in my case. ### Expected Behavior The cursor should not jump forward when single-letter replacement mode is triggered. ### Actual Behavior The cursor jumps forward, as noted above. Note that I've tested this same combination of factors in WSL Vim, and the jump does not occur.
Author
Owner

@zadjii-msft commented on GitHub (Aug 5, 2021):

I've tested this same combination of factors in WSL Vim, and the jump does not occur.

Ooooh. That's a good observation. The issue might have a root cause in Win32 Vim's VT parser. @DHowett will take a look.

@zadjii-msft commented on GitHub (Aug 5, 2021): > I've tested this same combination of factors in WSL Vim, and the jump does not occur. Ooooh. That's a good observation. The issue might have a root cause in Win32 Vim's VT parser. @DHowett will take a look.
Author
Owner

@DHowett commented on GitHub (Aug 5, 2021):

This is unfortunately a vim issue.

When it is printing the t_SR value to the screen (and t_SI!), it's dumping the escape characters directly to the screen without letting us parse them. Here's what it looks like in the console host:

vim-win32-bad

This likely stems from the fact that vim.exe does not support escape sequences on Windows. When it is connected to Terminal, they accidentally work. This is only an accident -- vim has not put the console in the correct mode to handle this. As a result, though, the cursor virtually moves over to cover the raw sequence (as it should.)

The real bug is unfortunately that Terminal doesn't handle it like Console does.

@DHowett commented on GitHub (Aug 5, 2021): This is unfortunately a vim issue. When it is printing the `t_SR` value to the screen (and `t_SI`!), it's dumping the escape characters **directly to the screen without letting us parse them.** Here's what it looks like in the console host: ![vim-win32-bad](https://user-images.githubusercontent.com/189190/128424989-04560664-1cad-428e-9360-c3e517ee8bbe.gif) This likely stems from the fact that **vim.exe does not support escape sequences on Windows**. When it is connected to Terminal, they _accidentally_ work. This is only an accident -- vim has not put the console in the correct mode to handle this. As a result, though, the cursor virtually moves over to cover the raw sequence (as it should.) The real bug is unfortunately that Terminal doesn't handle it like Console does.
Author
Owner

@LRitzdorf commented on GitHub (Aug 6, 2021):

Rats, that's unfortunate. Thanks for the information, though!

@LRitzdorf commented on GitHub (Aug 6, 2021): Rats, that's unfortunate. Thanks for the information, though!
Author
Owner

@alexeicolin commented on GitHub (Nov 12, 2022):

UPDATE: issue fixed in vim 9.0.

P.S. Related issue of restoring cursor when exiting vim back into PowerShell, solved using this solution: add to PowerShell profile:

function vim {
        & "C:\Program Files (x86)\Vim\vim82\vim.exe" $args && echo "`e[5 q"
}
@alexeicolin commented on GitHub (Nov 12, 2022): UPDATE: issue fixed in vim 9.0. P.S. Related issue of restoring cursor when exiting vim back into PowerShell, solved using [this solution](https://github.com/microsoft/terminal/issues/4335#issuecomment-1238989185): add to PowerShell profile: ``` function vim { & "C:\Program Files (x86)\Vim\vim82\vim.exe" $args && echo "`e[5 q" } ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14731