You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Consider supporting [extension to VT,] DECSCUSR "0" to restore cursor to user default to help vim/others #1604
I'm not sure what escape sequences Windows Terminal supports for changing the cursor shape, nor what (Neo)Vim outputs, so sorry if I get it wrong.
I assume that the DECSCUSR escape sequence is being used (see e.g. at ctlseqs.html).
In gnome-terminal (vte) we intentionally deviate from the xterm's behavior (the behavior documented on the linked page). For parameters 1–6 we go with the given mode. However, if the parameter is 0 (or missing), we revert to whichever cursor shape the user specified as their favorite in the terminal's preferences.
This might be a behavior for WIndows Terminal to consider, too.
This is actually intended behavior for Vim/Nvim and I can't recall any sort of "restore cursor leaving application mode" termcap that could be implemented in the terminal.
And yes, that's correct... DECSCUSR has been implemented in WindowsTerminal for changing cursor shape (1-6).
Vim explicitly changes the cursor shape for each of it's editing modes and it requires that you assign the ESC sequences in your vimrc file, as they are not using any sort of standard termcap variable for this.
Vim does not change the cursor shape on exit. The cursor shape from normal mode will remain, since you must exit from normal mode.
For more info in Vim: :help termcap-cursor-shape
It's easy to change the cursor shape upon exit for yourself using an autocmd VimLeave :help VimLeave
Doug (@xtremeperf) Thanks for your tip!
Found a possible solution on neovim/neovim#4867.
Adding au VimLeave * set guicursor=a:hor10-blinkon1 gives a blinking underscore when you exit vim
One problem is the lack of save/restore or revert, which we somewhat address in gnome-terminal by deviating from the standard. This way vim could restore the user's preferred version on exit.
The other problem is that two orthogonal properties are tied together. For an app like vim, it really makes sense to toggle between two different shapes, while leave blinking at the user's preferred setting. It's currently not possible.
The best solution could be to cooperate between terminal emulators and apps to come up with a better designed escape sequence. Until then, we live with the limitations, and optionally come up with hacks to mitigate the problems.
I'd like to see one or two more terminals commit to this before making the change, though. I'm sure it will break some users' configurations, and it's only justifiable if it's the clear path forward.
George Nachman (@gnachman) I've done a bit of testing on the terminals I have installed, and there are actually a few that support this extension. Other than VTE, there's also mintty and alacritty, which support both 0 and a missing parameter for selecting the user's preferred cursor. Then there is kitty (the Linux terminal, not the putty fork) which supports only 0 (a missing parameter selects the block cursor).
I still think DECRQSS makes more sense for apps that actually want to restore the cursor shape (rather than just resetting it to a default value), but DECSCUSR 0 is not a bad fall back option.
Thanks for providing the additional context, James Holderness (@j4james) . I'm not a fan of DECRQSS for two reasons:
Using it casually (like in a shell script) is too hard.
Reporting in general is full of race conditions, where the reported code sometimes gets printed to the screen if the user hits a key, a program crashes, or an ssh connection ends at just the wrong moment.
I think the strongest argument in favor of adopting this change is that 0 is the same as 1. Anyone who has problems can fix them without too much trouble. Considering VTTY, mintty, and alacritty already support it, that's strong evidence that there is a lot of hard-to-fix software in the wild.
Activity
egmontkob commentedon Jun 25, 2019
I'm not sure what escape sequences Windows Terminal supports for changing the cursor shape, nor what (Neo)Vim outputs, so sorry if I get it wrong.
I assume that the DECSCUSR escape sequence is being used (see e.g. at ctlseqs.html).
In gnome-terminal (vte) we intentionally deviate from the xterm's behavior (the behavior documented on the linked page). For parameters 1–6 we go with the given mode. However, if the parameter is 0 (or missing), we revert to whichever cursor shape the user specified as their favorite in the terminal's preferences.
This might be a behavior for WIndows Terminal to consider, too.
xtremeperf commentedon Jun 27, 2019
This is actually intended behavior for Vim/Nvim and I can't recall any sort of "restore cursor leaving application mode" termcap that could be implemented in the terminal.
And yes, that's correct... DECSCUSR has been implemented in WindowsTerminal for changing cursor shape (1-6).
Vim explicitly changes the cursor shape for each of it's editing modes and it requires that you assign the ESC sequences in your vimrc file, as they are not using any sort of standard termcap variable for this.
Vim does not change the cursor shape on exit. The cursor shape from normal mode will remain, since you must exit from normal mode.
For more info in Vim:
:help termcap-cursor-shapeIt's easy to change the cursor shape upon exit for yourself using an
autocmd VimLeave:help VimLeaveI hope that helps!
jtourlamain commentedon Jun 27, 2019
Doug (@xtremeperf) Thanks for your tip!
Found a possible solution on neovim/neovim#4867.
Adding
au VimLeave * set guicursor=a:hor10-blinkon1gives a blinking underscore when you exit vimegmontkob commentedon Jun 27, 2019
The DECSCUSR sequence is a poorly designed one.
One problem is the lack of save/restore or revert, which we somewhat address in gnome-terminal by deviating from the standard. This way vim could restore the user's preferred version on exit.
The other problem is that two orthogonal properties are tied together. For an app like vim, it really makes sense to toggle between two different shapes, while leave blinking at the user's preferred setting. It's currently not possible.
The best solution could be to cooperate between terminal emulators and apps to come up with a better designed escape sequence. Until then, we live with the limitations, and optionally come up with hacks to mitigate the problems.
DHowett-MSFT commentedon Jun 27, 2019
I like the idea of using a nonstandard
DECSCUSRextension to reset the cursor to "user default."DHowett-MSFT commentedon Jun 27, 2019
I'll float that to Mike Griese (@zadjii-msft) -- if we don't want to do it, we'll close this issue as "unfortunately by design". 😄
21 remaining items
gnachman commentedon Mar 14, 2020
I'm supportive of the proposal to repurpose 0 to restore the user's default in iTerm2, which came to my attention here: https://gitlab.com/gnachman/iterm2/-/issues/8769
I'd like to see one or two more terminals commit to this before making the change, though. I'm sure it will break some users' configurations, and it's only justifiable if it's the clear path forward.
j4james commentedon Mar 14, 2020
George Nachman (@gnachman) I've done a bit of testing on the terminals I have installed, and there are actually a few that support this extension. Other than VTE, there's also mintty and alacritty, which support both 0 and a missing parameter for selecting the user's preferred cursor. Then there is kitty (the Linux terminal, not the putty fork) which supports only 0 (a missing parameter selects the block cursor).
I still think
DECRQSSmakes more sense for apps that actually want to restore the cursor shape (rather than just resetting it to a default value), butDECSCUSR 0is not a bad fall back option.gnachman commentedon Mar 14, 2020
Thanks for providing the additional context, James Holderness (@j4james) . I'm not a fan of DECRQSS for two reasons:
I think the strongest argument in favor of adopting this change is that 0 is the same as 1. Anyone who has problems can fix them without too much trouble. Considering VTTY, mintty, and alacritty already support it, that's strong evidence that there is a lot of hard-to-fix software in the wild.
gnachman commentedon May 14, 2020
FYI I've implemented DECSCUSR 0 to reset cursor style & blink in gnachman/iTerm2@5680f97
Add support for DECSCUSR "0" to restore cursor to user default (#7379)
DHowett commentedon Oct 14, 2020
The fix for this issue was just released as part of Windows in Insider Build 20236!
feat(inline): respect the user's terminal cursor -- idle caret shape …