[vim/vim] Allow listchars to inherit visual selection highlighting (PR #18167)

23 views
Skip to first unread message

glepnir

unread,
Aug 30, 2025, 2:43:46 AM8/30/25
to vim/vim, Subscribed

Problem: Listchars aintain their SpecialKey highlighting when within a visual selection, unlike regular text which adopts Visual highlighting.

Solution: Remove attr_pri restriction in attribute combination logic to allow listchars display in visual mode, combining extra_attr with existing char_attr when visual selection is active.

relate neovim/neovim#34189


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/18167

Commit Summary

  • 6e18ef6 Allow listchars to inherit visual selection highlighting

File Changes

(3 files)

Patch Links:


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

zeertzjq

unread,
Aug 30, 2025, 3:02:10 AM8/30/25
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/testdir/test_highlight.vim:

> @@ -1355,4 +1355,21 @@ func Test_hlset()
   call assert_true(hlget('hlg11')[0].cleared)
 endfunc
 
+func Test_listchars_with_visual()

Put this in test_listchars.vim?


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/pull/18167/review/3170918483@github.com>

h_east

unread,
Aug 30, 2025, 3:04:15 AM8/30/25
to vim/vim, Subscribed

@h-east commented on this pull request.


In src/drawline.c:

> +	    {
+		wlv.char_attr = hl_combine_attr(wlv.char_attr, wlv.extra_attr);
+	    }

The curly braces seems unnecessary.


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/pull/18167/review/3170919057@github.com>

zeertzjq

unread,
Aug 30, 2025, 3:04:33 AM8/30/25
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/drawline.c:

>  	    else
+	    {
+#ifdef LINE_ATTR
+		// Visual mode: combine listchars with visual selection color

This comment doesn't seem to belong here.


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/pull/18167/review/3170919095@github.com>

zeertzjq

unread,
Aug 30, 2025, 3:06:38 AM8/30/25
to vim/vim, Subscribed

@zeertzjq commented on this pull request.


In src/drawline.c:

>  	    else
+	    {
+#ifdef LINE_ATTR
+		// Visual mode: combine listchars with visual selection color

This comment doesn't seem to belong here. Visual selection highlighting isn't included in either line_attr or extra_attr.


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/pull/18167/review/3170919714@github.com>

glepnir

unread,
Aug 30, 2025, 3:08:13 AM8/30/25
to vim/vim, Push

@glepnir pushed 1 commit.

  • ef90ca3 Allow listchars to inherit visual selection highlighting


View it on GitHub or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/before/6e18ef696bdcc6e9d56d69b163b0ad6ceb67c445/after/ef90ca36c82da74e30d02e5ac67e70bdeba4eeda@github.com>

glepnir

unread,
Aug 30, 2025, 3:08:29 AM8/30/25
to vim/vim, Subscribed

@glepnir commented on this pull request.


In src/drawline.c:

>  	    else
+	    {
+#ifdef LINE_ATTR
+		// Visual mode: combine listchars with visual selection color

yep forget remove


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/pull/18167/review/3170920177@github.com>

glepnir

unread,
Aug 30, 2025, 3:09:21 AM8/30/25
to vim/vim, Push

@glepnir pushed 1 commit.

  • 815427c Allow listchars to inherit visual selection highlighting

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/before/ef90ca36c82da74e30d02e5ac67e70bdeba4eeda/after/815427c10cc9faafd48d84b5c543926ab162cb04@github.com>

Maxim Kim

unread,
Aug 30, 2025, 7:25:04 PM8/30/25
to vim/vim, Subscribed
habamax left a comment (vim/vim#18167)

Looks good for Visual with no foreground defined:

image.png (view on web) image.png (view on web)

Looks bad for visual with foreground defined and reverse:

image.png (view on web) image.png (view on web) image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/c3239602183@github.com>

glepnir

unread,
Sep 1, 2025, 6:12:14 AM9/1/25
to vim/vim, Push

@glepnir pushed 1 commit.

  • a32a2f5 feat: listchars only in visual mode

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/before/815427c10cc9faafd48d84b5c543926ab162cb04/after/a32a2f55d7443a30a6556da9a5e443075f927763@github.com>

glepnir

unread,
Sep 1, 2025, 6:15:38 AM9/1/25
to vim/vim, Push

@glepnir pushed 1 commit.

  • 5818b3f feat: listchars only in visual mode

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/before/a32a2f55d7443a30a6556da9a5e443075f927763/after/5818b3fde5a3e5f33edd820663eb3233ae5ff83d@github.com>

zeertzjq

unread,
Sep 1, 2025, 6:23:04 AM9/1/25
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18167)

'listchars' are only displayed during Visual mode within the selected area

This will complicate the size computation of TABs and the cursor positioning on TABs, as they depend on whether 'list' and 'listchars' tab field are used, and with this 'visuallist' they'll have to depend on whether the TAB is in the Visual selection as well. And if the Visual selection only covers a part of a TAB (in blockwise mode), things may get even more complicated.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/c3241796192@github.com>

glepnir

unread,
Sep 1, 2025, 6:24:19 AM9/1/25
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18167)

Yes. The previous change altered the merge priority. The original issue has been updated to request supporting listchars only when in Visual mode. Currently, a new option visuallist has been added (a better name would be welcome) that shows the selected area's listchars only when in Visual mode, using the VisualSpecialKey highlight group. Sorry, I collapsed your comment — there were a bit too many images, which made browsing here quite lengthy.. there are some uncertain parts… I might need you to take a look and help @zeertzjq


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/pull/18167/c3241799582@github.com>

zeertzjq

unread,
Sep 1, 2025, 6:25:17 AM9/1/25
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18167)

'listchars' are only displayed during Visual mode within the selected area

This will complicate the size computation of TABs and the cursor positioning on TABs, as they depend on whether 'list' and 'listchars' tab field are used, and with this 'visuallist' they'll have to depend on whether the TAB is in the Visual selection as well. And if the (blockwise) Visual selection only covers a part of a TAB, things may get even more complicated.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/c3241802394@github.com>

glepnir

unread,
Sep 1, 2025, 6:26:51 AM9/1/25
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18167)

Lol, your reply was so fast that I hadn’t refreshed the page yet. Wouldn’t it be enough to just control a variable and attribute for whether to render listchars? No other calculations need to be changed.


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/pull/18167/c3241806718@github.com>

zeertzjq

unread,
Sep 1, 2025, 6:38:42 AM9/1/25
to vim/vim, Subscribed
zeertzjq left a comment (vim/vim#18167)

Wouldn’t it be enough to just control a variable and attribute for whether to render listchars?

No. Because

  1. If 'list' is set and tab isn't present in 'listchars', a TAB is rendered as ^I or <09>.
  2. If 'list' is set, cursor is placed on the first cell on the TAB, otherwise it's placed on the last cell.

So if you change whether 'list' is applied to depend on the Visual selection, these will have to depend on the Visual selection as well.


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/pull/18167/c3241853247@github.com>

Maxim Kim

unread,
Sep 1, 2025, 6:41:47 AM9/1/25
to vim/vim, Subscribed
habamax left a comment (vim/vim#18167)

'listchars' are only displayed during Visual mode within the selected area

This will complicate the size computation of TABs and the cursor positioning on TABs, as they depend on whether 'list' and 'listchars' tab field are used, and with this 'visuallist' they'll have to depend on whether the TAB is in the Visual selection as well. And if the (blockwise) Visual selection only covers a part of a TAB, things may get even more complicated.

That is what I was thinking looking at the updated docs here in PR.

What would happen to those partial tabs in blockwise selection?
image.png (view on web)


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/c3241877686@github.com>

glepnir

unread,
Sep 1, 2025, 6:58:41 AM9/1/25
to vim/vim, Subscribed
glepnir left a comment (vim/vim#18167)

Thanks. I’ll try these cases ..


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/pull/18167/c3241926171@github.com>

Christian Brabandt

unread,
Sep 1, 2025, 1:12:56 PM9/1/25
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18167)

Isn't this something that could be achieved using a ModeChanged autocommand?


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/pull/18167/c3242953769@github.com>

Christian Brabandt

unread,
Jun 13, 2026, 4:10:23 PM (10 hours ago) Jun 13
to vim/vim, Subscribed
chrisbra left a comment (vim/vim#18167)

this has stalled, so closing


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/pull/18167/c4699652952@github.com>

Reply all
Reply to author
Forward
0 new messages