[vim/vim] Highlight the line number columns of not-current windows independently (#5332)

27 views
Skip to first unread message

Leonardo

unread,
Dec 8, 2019, 5:20:22 PM12/8/19
to vim/vim, Subscribed

Is your feature request related something that is currently hard to do? Please describe.

I would like to be able to highlight the line number columns of not-current windows independently of the focused one's. That would allow for more focus on the current window.

Describe the solution you'd like

Two new highlight groups: LineNrNC and CursorLineNrNC, NC being "not-current", just like StatusLineNC.

Additional context

This illustrates the scenario:

Annotation 2019-12-08 1919


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

Christian Brabandt

unread,
Dec 8, 2019, 9:27:48 PM12/8/19
to vim...@googlegroups.com, vim/vim, Subscribed
How about scripting and changing the highlighting around a WinLeave autocommand?

Am 08.12.2019 um 23:20 schrieb Leonardo (Vim Github Repository) <vim-dev...@256bit.org>:


--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_dev/vim/vim/issues/5332%40github.com.

Christian Brabandt

unread,
Dec 9, 2019, 3:33:07 PM12/9/19
to vim/vim, Subscribed

wouldn't it be more useful, to simply remove the LineNr and CursorLinenr in the non current window? I think this can be configured using some auto commands.

Dennis B

unread,
Jul 7, 2020, 1:11:59 AM7/7/20
to vim/vim, Subscribed

wouldn't it be more useful, to simply remove the LineNr and CursorLinenr in the non current window? I think this can be configured using some auto commands.

Doing that would result in the non-current window content shifting a couple characters to the left (as the number column disappears). When hopping around a series of split-windows content would be shifting left and right as the line number column disappears and appears.

It does not look good in practice.

LineNrNC would be useful to achieve colorscheme consistency whilst locking content in-place when the background is changed for inactive windows.

bfrg

unread,
Jul 7, 2020, 6:22:32 PM7/7/20
to vim/vim, Subscribed

Vim doesn't provide a NormalNC highlight group. What you're asking for is a very specific use case.

Changing the color of inactive windows is achieved through the window-local option 'wincolor', for example:

augroup dim_inactive_win
    autocmd!
    autocmd WinEnter * setlocal wincolor=
    autocmd WinLeave * setlocal wincolor=NormalNC
augroup END

NormalNC is a random name, it could be anything else. The above is just one specific example of using wincolor. Someone else might want to set specific wincolor based on the filetype, or whether it's a test, header, or implementation file. IIRC the option was originally added to let users set different colors for popup windows.

If more window-local color settings were to be added, then it should probably be something similar to wincolor for consistency. But keep in mind, if you add another option for the line number column, then it's just a matter of time until someone asks for a color option for signcolumn and foldcolumn, and as you already mentioned the cursorline (or cursor line column).

So, in total this would mean adding four new window-local color options, maybe something like:

  • numbercolor
  • foldcolumncolor
  • signcolumncolor
  • cursorlinecolor (and/or cursorcolumncolor)

Leonardo

unread,
Jul 7, 2020, 7:47:07 PM7/7/20
to vim/vim, Subscribed

Vim doesn't even provide a NormalNC highlight group. What you're asking for is a very specific use case.

Changing the color of inactive windows is achieved through the window-local option 'wincolor', for example:

augroup dim_inactive_win
    autocmd!
    autocmd WinEnter * setlocal wincolor=
    autocmd WinLeave * setlocal wincolor=NormalNC
augroup END

NormalNC is a random name, it could be anything else. The above is just one specific example of using wincolor. Someone else might want to set specific wincolor based on the filetype, or whether it's a test, header, or implementation file. IIRC the option was originally added to let users set different colors for popup windows.

If more window-local color settings were to be added, then it should probably be something similar to wincolor for consistency. But keep in mind, if you add another option for the line number column, then it's just a matter of time until someone asks for a color option for signcolumn and foldcolumn, and as you already mentioned the cursorline (or cursor line column).

So, in total this would mean adding four new window-local color options, maybe something like:

* `numbercolor`

* `foldcolumncolor`

* `signcolumncolor`

* `cursorlinecolor` (and/or `cursorcolumncolor`)

Setting wincolor does override LineNr's background color, but not the foreground. That is already better than what the method from the plugin I use (vim-diminactive) does (which consists in using colorcolumn). The plugin obviously has compatibility constraints: it has to work on older versions of Vim and Neovim.

I don't know, instead of adding lots of variables, maybe wincolor could accept a highlight group or a dictionary literal with those hypothetical variable names as keys.

Reply all
Reply to author
Forward
0 new messages