[vim/vim] cursor blink behavor changed after starting/quit vim in windows powershell (Issue #11906)

9 views
Skip to first unread message

colo9

unread,
Jan 28, 2023, 10:05:58 PM1/28/23
to vim/vim, Subscribed

Steps to reproduce

  1. in powershell's $PROFILE, add Write-Host -NoNewLine "e[2 q"` line to disable cursor blink
  2. open a new window which started with no cursor blink, then run vim, and you will find cursor start blinking again
  3. :q to quit vim, and cursor still in blink state.

Expected behaviour

vim should not change the cursor behavior

Version of Vim

9.0.1194

Environment

Operating system: windows 11
Terminal: windows terminal
Shell: Powershell 7.2.8

Logs and stack traces

No response


Reply to this email directly, view it on GitHub.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906@github.com>

Christopher Plewright

unread,
Jan 29, 2023, 12:07:47 AM1/29/23
to vim/vim, Subscribed

There is a chance that this was fixed in patch 9.0.1252 - that fixed a bug how Vim restores the MS-Windows console buffer on exit - it would impact the new windows terminal as well as the old command console.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1407563531@github.com>

Christopher Plewright

unread,
Jan 29, 2023, 12:45:55 AM1/29/23
to vim/vim, Subscribed

Ah, hang on - something else I remember,
Vim does change the cursor shape - that is by design.
But, you can configure it how you like - for example in my .vimrc file;

This works on windows terminal;

augroup CursorSettings
    autocmd! 
    " Alternative codes:
    "  1 -> blinking block
    "  2 -> solid block 
    "  3 -> blinking underscore
    "  4 -> solid underscore
    "  5 -> blinking vertical bar
    "  6 -> solid vertical bar

    autocmd VimEnter * let &t_SI.="\e[5 q" "SI = INSERT mode
    autocmd VimEnter * let &t_SR.="\e[4 q" "SR = REPLACE mode
    autocmd VimEnter * let &t_EI.="\e[2 q" "EI = NORMAL mode (ELSE)

    autocmd VimLeave * let &t_EI.="\e[6 q" | normal i
augroup END


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1407568568@github.com>

Christopher Plewright

unread,
Jan 29, 2023, 12:49:33 AM1/29/23
to vim/vim, Subscribed

You can change the VimLeave line, to match your custom terminal cursor style.

autocmd VimLeave * let &t_EI.="\e[2 q" | normal i


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1407569139@github.com>

colo9

unread,
Jan 30, 2023, 1:27:17 AM1/30/23
to vim/vim, Subscribed

There is a chance that this was fixed in patch 9.0.1252 - that fixed a bug how Vim restores the MS-Windows console buffer on exit - it would impact the new windows terminal as well as the old command console.

Ah, that's pretty nice,thank you very much.


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408064441@github.com>

colo9

unread,
Jan 30, 2023, 1:39:20 AM1/30/23
to vim/vim, Subscribed

Ah, hang on - something else I remember, Vim does change the cursor shape - that is by design. But, you can configure it how you like - for example in my .vimrc file;

This works on windows terminal;

augroup CursorSettings
    autocmd! 
    " Alternative codes:
    "  1 -> blinking block
    "  2 -> solid block 
    "  3 -> blinking underscore
    "  4 -> solid underscore
    "  5 -> blinking vertical bar
    "  6 -> solid vertical bar

    autocmd VimEnter * let &t_SI.="\e[5 q" "SI = INSERT mode
    autocmd VimEnter * let &t_SR.="\e[4 q" "SR = REPLACE mode
    autocmd VimEnter * let &t_EI.="\e[2 q" "EI = NORMAL mode (ELSE)

    autocmd VimLeave * let &t_EI.="\e[6 q" | normal i
augroup END

I tried but failed with some mistakes which i haven't figured out, i will retest my config, Thank you~~


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408073064@github.com>

K.Takata

unread,
Jan 30, 2023, 1:49:55 AM1/30/23
to vim/vim, Subscribed

See also :help termcap-cursor-shape:

https://github.com/vim/vim/blob/2a99fe6c41efcd5d1eb47823e7e73cf391e230ba/runtime/doc/term.txt#L735-L744


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408079895@github.com>

Christopher Plewright

unread,
Jan 30, 2023, 2:49:36 AM1/30/23
to vim/vim, Subscribed

@k-takata

About this bit -

NOTE: When Vim exits the shape for Normal mode will remain. The shape from before Vim started will not be restored.

I found it's possible to hook into the VimLeave auto-command, and make it switch the cursor back to the insert mode cursor at the end:
autocmd VimLeave * let &t_SI.="\e[6 q" | normal i

Maybe I've been relying on an undocumented "feature", but I found I could get it to set the insert mode cursor on exit. The | normal i bit achieves that.

I'm assuming this is still the case. I just realised that the stuff before the | may be completely redundant, I can't recall now why I did it like that. Anyway, I was able to get the insert mode cursor restored to the console again on exit.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408133586@github.com>

Christopher Plewright

unread,
Jan 30, 2023, 3:57:46 AM1/30/23
to vim/vim, Subscribed

arghh, I'm just testing all this now on latest release of Windows 11 (22H2).
It's not behaving the same anymore like it was when I first set it up on windows 10 - that was maybe two or three years ago.
So, I'm investigating further. Its all a bit strange. I'm getting underscore when I set to block, I'm getting block when I set to bar etc. It's really weird at the moment.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408212475@github.com>

K.Takata

unread,
Jan 30, 2023, 5:20:41 AM1/30/23
to vim/vim, Subscribed

I haven't looked into this yet, but v9.0.0347 might be related.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408348115@github.com>

Christopher Plewright

unread,
Jan 30, 2023, 5:43:02 AM1/30/23
to vim/vim, Subscribed

Related, but OK I think.
I cleaned out my vimrc, trying to keep things simple - and it looks like it still works OK - if I just do a minimal set like this;

let &t_SI.="\e[5 q"  "t_SI = Start INSERT mode
let &t_SR.="\e[4 q"  "t_SR = Start REPLACE mode
let &t_EI.="\e[2 q"  "t_EI = End Insert mode - usually starts NORMAL mode
let &t_te.="\e[0 q"  "t_te = Termcap End - usually called when exiting Vim.

and when I just have that (without the auto-command) - it seems to work OK. The termcap end (t_te) seems to be a new trick that I didn't know about before when I first set all this up in my environment - t_te is so much cleaner than hooking into VimLeave. Also, it seems that "\e[0 q" is working now properly. That was confusing me. But, I think it's actually better the way it is now.

I suggest that the only line @clor09 needs (to achieve their initial expected outcome as written) is just this one line in the vimrc;

let &t_te.="\e[0 q"

I'm assuming @clor09 is on Win 11 release 22H2


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408388439@github.com>

Christopher Plewright

unread,
Jan 30, 2023, 5:44:43 AM1/30/23
to vim/vim, Subscribed

FYI - Reference: https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences#cursor-shape


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408390643@github.com>

Christopher Plewright

unread,
Jan 30, 2023, 6:03:39 AM1/30/23
to vim/vim, Subscribed

@k-takata

I found the cause of my confusion. I must have moved things around in my vimrc, some time ago, and somehow had set termguicolors after setting the cursor settings.

@clor09
Note, in the vimrc file, all these cursor settings must come down after setting up the colorscheme and termguicolors (if you set them.)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/1408415640@github.com>

Benjamin Wall

unread,
Jun 18, 2025, 5:39:40 AM6/18/25
to vim/vim, Subscribed
ben-wall left a comment (vim/vim#11906)

Ah, hang on - something else I remember, Vim does change the cursor shape - that is by design. But, you can configure it how you like - for example in my .vimrc file;

This works on windows terminal;

augroup CursorSettings
    autocmd! 
    " Alternative codes:
    "  1 -> blinking block
    "  2 -> solid block 
    "  3 -> blinking underscore
    "  4 -> solid underscore
    "  5 -> blinking vertical bar
    "  6 -> solid vertical bar

    autocmd VimEnter * let &t_SI.="\e[5 q" "SI = INSERT mode
    autocmd VimEnter * let &t_SR.="\e[4 q" "SR = REPLACE mode
    autocmd VimEnter * let &t_EI.="\e[2 q" "EI = NORMAL mode (ELSE)

    autocmd VimLeave * let &t_EI.="\e[6 q" | normal i
augroup END

thank you so much


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/11906/2983442064@github.com>

Reply all
Reply to author
Forward
0 new messages