[vim/vim] `hi clear` with `bg=dark` results in some highlight groups being cleared that aren't cleared when `bg=light` (Issue #18540)

11 views
Skip to first unread message

John T. Wodder II

unread,
Oct 10, 2025, 2:11:53 PMOct 10
to vim/vim, Subscribed
jwodder created an issue (vim/vim#18540)

Steps to reproduce

~/.vim/vimrc:

syntax on
colorscheme empty

~/.vim/colors/empty.vim:

highlight clear
if exists("syntax_on")
    syntax reset
endif
let g:colors_name="empty"

Save the following reStructuredText document to foo.rst:

**Bold** and *brash*

If foo.rst is opened in an environment in which bg=light, then the "Bold" text will be highlighted bold, and the "brash" text will be highlighted italic, as expected. However, if bg=dark upon opening the file, then no styling will be applied to the text.

Expected behaviour

The "Bold" and "brash" text should be highlighted bold & italic, respectively, regardless of whether bg is light or dark.

Version of Vim

9.1.1800

Environment

OS: macOS Sonoma 14.7.8
Terminal: WezTerm 20240203-110809-5046fc22
TERM: xterm-256color

Logs and stack traces


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/18540@github.com>

Christian Brabandt

unread,
Oct 10, 2025, 5:37:46 PMOct 10
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18540)

However, if bg=dark upon opening the file, then no styling will be applied to the text.

What does that mean? You set it after loading the colorscheme?

I think what is happening here is, that when the default background is set (which is light on most systems except for the Win32 console version), the highlighting isn't reset. But later setting the background will re-initialize the highlighting groups and therefore clear the existing highlighting groups.

Which means, if you do vim -u vimrc --noplugins --cmd 'set bg=dark' foo.rst the highlighting is correct even with a dark background.

I think this is just the way how colorschemes and highlighting works in combination with setting the background color.


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/18540/3392373211@github.com>

John T. Wodder II

unread,
Oct 10, 2025, 6:36:22 PMOct 10
to vim/vim, Subscribed
jwodder left a comment (vim/vim#18540)

No, I mean that, if you are using a terminal that Vim autodetects as having a dark background, then no styling is applied. I'm not doing an explicit set bg=dark at any point.


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/18540/3392497805@github.com>

Christian Brabandt

unread,
Oct 11, 2025, 2:13:11 AMOct 11
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18540)

Well this is probably the same thing. Switching the background option causes the highlighting groups to be reset


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/18540/3392965888@github.com>

Christian Brabandt

unread,
Nov 12, 2025, 3:14:02 PM (13 hours ago) Nov 12
to vim/vim, Subscribed

Closed #18540 as not planned.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/18540/issue_event/20897758787@github.com>

Christian Brabandt

unread,
Nov 12, 2025, 3:14:02 PM (13 hours ago) Nov 12
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18540)

I think we should probably rather make use of the new bold and italic highlighting groups, rather than setting those attributes directly as you already mentioned. Please open a new issue/PR when you noticed such a thing.


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/18540/3523727518@github.com>

Reply all
Reply to author
Forward
0 new messages