2

I want the cursor line number to have a different color than the rest of numbers with cursorline disabled.

Sadly CursorLineNR is only active if set cursorline. I could do set cursorline followed by hi clear CursorLine with hi CursorLineNR, however I want cursorline to be visible when set and not visible when not set, and still have the cursor line number have a different color.

With set cursorline + hi CursorLineNr guifg=#af00af:

enter image description here

but when doing set nocursorline it disappears:

enter image description here

I want the 197 number to always be guifg=#af00af, even after set nocursorline. Is this anyhow possible?

Ie. compare:

vim -u NONE -c 'hi CursorLineNr guibg=#ff0000 ctermbg=red' -c 'set number relativenumber' -c 'exe "normal i\<cr>- should be red\<cr>\<up>\<esc>"' -c 'set nocursorline'

vs the same with cursorline in the last argument (or do :set cursorline). The same above command when run with neovim makes the number line in red in both cases.

  • 1
    CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' is set to "number" or "both", or 'relativenumber' is set, for the cursor line. --should be used when rnu is set no matter what? Having said that, my vim does what yours does. Perhaps a bug? Or perhaps the wordings means ('cul') & ('cursorlineopt' | 'rnu') – D. Ben Knoble Nov 11 '20 at 21:29
3

You need these three lines:

hi CursorLineNr guifg=#af00af
set cursorline
set cursorlineopt=number

The last line removes the highlighting of the cursor line even if cursorline is set and only highlights the cursor line number.

  • 1
    Very nice, note, this needs at least 8.1.2019 I believe – Christian Brabandt Nov 12 '20 at 8:58
  • 1
    @ChristianBrabandt Yes, and 8.1.2155 if it's to be used in a terminal window (which is probably not the case here). – Jürgen Krämer Nov 12 '20 at 9:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.