[vim/vim] Vim changes cursor to pink and keeps it on exit (t_Cs, TERM=tmux-256color, urxvt) (#3471)

52 views
Skip to first unread message

Daniel Hahler

unread,
Sep 22, 2018, 5:23:26 AM9/22/18
to vim/vim, Subscribed

Given t-undercurl-pink.vim:

let &term = 'tmux-256color'
hi SpellBad cterm=undercurl
set spell

vim -Nu t-undercurl-pink.vim t-undercurl-pink.vim will cause a pink cursor color for me (with rxvt-unicode as the terminal), and keeps it on exit. It does not happen when using gnome-terminal.

This appears to be related to t_Cs being set incorrectly:

% TERM=tmux-256color vim --cmd 'echom &t_Cs' -c q
^[]12;%p1%s^G

Via #2424 (comment).
I've just tried #2126, but it does not appear to fix it.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub

Daniel Hahler

unread,
Sep 25, 2018, 2:17:11 PM9/25/18
to vim/vim, Subscribed

Figured out what is going on: tmux itself has a Cs extension to set the cursor color (and Cr to reset it).

It does not show up in infocmp by default, but only with -x:

TERM=tmux-256color infocmp -A /usr/share/terminfo -x | grep Cs
Cs=\E]12;%p1%s\007

Pink appears to be the default here without an argument, but it can be set to red using TERM=tmux-256color tput Cs 1 etc.

What can be done about this?

a) Should Vim look into terminfo (via TGETSTR/tgetstrr I assume) for its internal extensions (all of https://github.com/vim/vim/blob/c75878c923034b883090aef3f08f565513d98f4d/runtime/doc/term.txt#L321-L358?) after all?
b) Should t_Cs only be used if t_Ce (to end it) is also set?

Bram Moolenaar

unread,
Sep 25, 2018, 4:36:12 PM9/25/18
to vim/vim, Subscribed

Daniel Hahler wrote:

> Figured out what is going on: tmux itself has a `Cs` extension to set the cursor color (and `Cr` to reset it).
>
> It does not show up in `infocmp` by default, but only with `-x`:
> ```
> TERM=tmux-256color infocmp -A /usr/share/terminfo -x | grep Cs
> Cs=\E]12;%p1%s\007
> ```
>
> Pink appears to be the default here without an argument, but it can be set to red using `TERM=tmux-256color tput Cs 1` etc.
>
> What can be done about this?
>
> a) Should Vim look into terminfo (via `TGETSTR`/`tgetstrr` I assume) for its internal extensions (all of https://github.com/vim/vim/blob/c75878c923034b883090aef3f08f565513d98f4d/runtime/doc/term.txt#L321-L358?) after all?

Should already happen in get_term_entries().


> b) Should `t_Cs` only be used if `t_Ce` (to end it) is also set?

We usually do this, yes.

--
hundred-and-one symptoms of being an internet addict:
102. When filling out your driver's license application, you give
your IP address.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Daniel Hahler

unread,
Sep 25, 2018, 4:51:38 PM9/25/18
to vim/vim, Subscribed

Just to be clear: I've meant to skip looking for "Cs", "Ce" etc, but it looks like it is handled normally? (i.e. looked up) - https://github.com/vim/vim/blob/c75878c923034b883090aef3f08f565513d98f4d/src/term.c#L1589

I think using b) here also would then fix it already, but I still think that querying for non-standard options could be skipped maybe. OTOH querying them allows you to set them in your terminfo file instead of vimrc, not sure about that though.

Josh Klodnicki

unread,
Sep 26, 2018, 10:38:47 AM9/26/18
to vim/vim, Subscribed

Figured out what is going on:

It does not show up in infocmp by default, but only with -x

@blueyed Thanks for looking into this. I didn't know about -x, that would have saved me hours of confusion last time around.

tmux itself has a Cs extension to set the cursor color (and Cr to reset it).

This is not just an obscure tmux extension, it is in the xterm terminfo as well:

$ TERM=xterm infocmp -1x | grep C[sr]
        Cr=\E]112\007,
        Cs=\E]12;%p1%s\007,

a) Should Vim look into terminfo (via TGETSTR/tgetstrr I assume) for its internal extensions (all of ?) after all?

Should already happen in get_term_entries().

The problem here is a naming conflict between the terminals' extensions and Vim's internal extensions.
Vim queries the Cs entry assuming it represents the undercurl sequence, when in fact it represents the cursor color sequence.

Maybe Vim should take into account the names widely agreed upon for well-known terminfo extensions.

Rud

unread,
Nov 15, 2018, 10:51:03 AM11/15/18
to vim/vim, Subscribed

Is there any workaround or fix for now? @blueyed @joshklod

Daniel Hahler

unread,
Nov 15, 2018, 11:56:41 AM11/15/18
to vim/vim, Subscribed

Not as far as I know - I am Neovim by default, so not really affected.

Josh Klodnicki

unread,
Nov 15, 2018, 1:26:28 PM11/15/18
to vim/vim, Subscribed

@rudevdr

Is there any workaround or fix for now?

Try adding :set t_Cs= to your .vimrc.

Kirill Chibisov

unread,
Apr 16, 2020, 4:59:14 AM4/16/20
to vim/vim, Subscribed

FWIW for undercurls vim should use https://man.openbsd.org/tmux#Smulx and check for it in particular. t_Cs is a tmux extension as it was mentioned above https://man.openbsd.org/tmux#Cs and since it's a part of xterm, each xterm derived terminfo has t_Cs. neovim for example checks for Smulx https://github.com/neovim/neovim/blob/e11e93d1394df83a93c83de5b60639f5085d69dd/src/nvim/tui/tui.c#L1952.


You are receiving this because you are subscribed to this thread.

Reply to this email directly, view it on GitHub, or unsubscribe.

Danilo Rezende

unread,
Jun 15, 2026, 3:38:45 AMJun 15
to vim/vim, Subscribed
returnDanilo left a comment (vim/vim#3471)

To whoever is fixing this in the future: I'll save you a few minutes and remind you that ncurse's tgetstr only looks at the first two characters if the id. So that won't work for getting Smulx. Maybe use tigetstr instead?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/3471/4705628207@github.com>

Josh Klodnicki

unread,
Jul 8, 2026, 1:47:55 PM (17 hours ago) Jul 8
to vim/vim, Subscribed
joshklod left a comment (vim/vim#3471)

Okay, but I'm not sure I understand your point. Vim doesn't use ncurses. Or am I missing something...?


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

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

Tony Mechelynck

unread,
Jul 8, 2026, 3:50:03 PM (15 hours ago) Jul 8
to vim/vim, Subscribed
tonymec left a comment (vim/vim#3471)

Okay, but I'm not sure I understand your point. Vim doesn't use ncurses. Or am I missing something...?

AFAIK, Vim does use ncurses when in Console mode. gvim doesn't.


Reply to this email directly, view it on GitHub, or unsubscribe.
Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS and Android. Download it today!

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

Reply all
Reply to author
Forward
0 new messages