Weird behavior after changing cursor shape in vim #7104

Closed
opened 2026-01-31 00:55:08 +00:00 by claunia · 2 comments
Owner

Originally created by @moetayuko on GitHub (Mar 23, 2020).

Environment

Windows build number: 10.0.18363.0
Windows Terminal version (if applicable): 0.10.761.0

Steps to reproduce

  1. Launch vim from either WSL or SSH of a Linux host
  2. Set cursor shape options: blinking block in normal mode, blinking vertical bar in insert mode
let &t_SI .= "\<Esc>[5 q"
let &t_EI .= "\<Esc>[0 q"

The shape does change as what we expect, but I observed weird behaviors after that.

Expected behavior

  1. When exiting insert mode, i.e. press i then <ESC>, the cursor stays at where it was if I didn't move it.
  2. When exiting insert mode, the cursor shape should change as soon as <ESC> pressed.
  3. Restore the default shape after exiting vim

Actual behavior

  1. Press i then <ESC>, the cursor moves ahead one character.
  2. The shape didn't change until the next blink.
  3. The cursor stays like a block after exiting.
Originally created by @moetayuko on GitHub (Mar 23, 2020). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> <!-- This bug tracker is monitored by Windows Terminal development team and other technical folks. **Important: When reporting BSODs or security issues, DO NOT attach memory dumps, logs, or traces to Github issues**. Instead, send dumps/traces to secure@microsoft.com, referencing this GitHub issue. If this is an application crash, please also provide a Feedback Hub submission link so we can find your diagnostic data on the backend. Use the category "Apps > Windows Terminal (Preview)" and choose "Share My Feedback" after submission to get the link. Please use this form and describe your issue, concisely but precisely, with as much detail as possible. --> # Environment ```none Windows build number: 10.0.18363.0 Windows Terminal version (if applicable): 0.10.761.0 ``` # Steps to reproduce <!-- A description of how to trigger this bug. --> 1. Launch vim from either WSL or SSH of a Linux host 2. Set cursor shape options: *blinking block* in normal mode, *blinking vertical bar* in insert mode ```vim let &t_SI .= "\<Esc>[5 q" let &t_EI .= "\<Esc>[0 q" ``` The shape does change as what we expect, but I observed weird behaviors after that. # Expected behavior <!-- A description of what you're expecting, possibly containing screenshots or reference material. --> 1. When exiting insert mode, i.e. press *i* then *\<ESC>*, the cursor stays at where it was if I didn't move it. 2. When exiting insert mode, the cursor shape should change as soon as *\<ESC>* pressed. 3. Restore the default shape after exiting vim # Actual behavior <!-- What's actually happening? --> 1. Press *i* then *\<ESC>*, the cursor moves ahead one character. 2. The shape didn't change until the next blink. 3. The cursor stays like a *block* after exiting.
claunia added the Resolution-By-DesignNeeds-Tag-Fix labels 2026-01-31 00:55:08 +00:00
Author
Owner

@j4james commented on GitHub (Mar 23, 2020):

  1. You can find an explanation of why the cursor moves backwards on the VIM stack exchange site. This is expected behaviour, and I see the same behaviour in other terminals emulators too.
  2. The delayed shape changing is because an ESC character can also be the start of a character sequence representing another key, so VIM needs to wait and see if there are more characters following before it can be certain you've actually pressed Esc. Again, this is expected behaviour.
  3. DECSCUSR 0 is officially defined as the block cursor so that's why you get a block on exit. Some terminals do interpret that as the user's preferred cursor, though, and it's possible we may support that one day too (see issue #1604)
@j4james commented on GitHub (Mar 23, 2020): 1. You can find an explanation of why the cursor moves backwards on the [VIM stack exchange](https://vi.stackexchange.com/a/3140) site. This is expected behaviour, and I see the same behaviour in other terminals emulators too. 2. The delayed shape changing is because an `ESC` character can also be the start of a character sequence representing another key, so VIM needs to wait and see if there are more characters following before it can be certain you've actually pressed <kbd>Esc</kbd>. Again, this is expected behaviour. 3. `DECSCUSR 0` is officially defined as the block cursor so that's why you get a block on exit. Some terminals do interpret that as the user's preferred cursor, though, and it's possible we may support that one day too (see issue #1604)
Author
Owner

@DHowett-MSFT commented on GitHub (Mar 23, 2020):

Thanks for the comprehensive writeup, James. 😄

@DHowett-MSFT commented on GitHub (Mar 23, 2020): Thanks for the comprehensive writeup, James. :smile:
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#7104