2

I have a vim configuration file (~/.vimrc) with the following settings:

colo delek
syntax on

highlight clear CursorLine
highlight clear CursorLineNR
highlight clear LineNR

highlight LineNR cterm=none ctermfg=Yellow ctermbg=none
highlight CursorLineNR cterm=bold ctermfg=Black ctermbg=none

This used to work fine, highlighting the current line number in Black, while the others remained Yellow. After I read about syntax enable, I tried it, replacing the syntax on command. Since then, the CursorLineNR highlighting has refused to work. I have tried changing changing the syntax command to off, enable and on in all orders but to no avail. I even tried changing the CursorLineNR from the command-line mode but that too doesn't work. It has to be noted though that the LineNR functionality works perfectly fine.

I work on a Macbook Air, with the following vim version:

VIM - Vi IMproved 8.0 (2016 Sep 12, compiled Nov 29 2017 18:37:46)
Included patches: 1-503, 505-680, 682-1283
  • So you're saying that the highlight has the values you expect (according to return value of :hi CursorLineNR) but those values are, as far as you can tell, being ignored? – B Layer Sep 8 '18 at 18:02
  • 1
    I had a similar problem and I solved it with set cursorline. – LuxGiammi Dec 23 '19 at 15:55
1

I think this is a bug. I my case, in vim 8.2, I can't highlight CursorLineNR when 'relativenumber' is set.

From the doc:

CursorLineNr Like LineNr when 'cursorline' is set and 'cursorlineopt' is set to "number" or "both", or 'relativenumber' is set, for the cursor line.

So, here's my workaround:

  • set 'cursorline'
  • highlight cursorline with the same values as for 'normal'
  • then highlight 'cursorlinenr'

I hope this helps :)

| improve this answer | |
0

In Vim you need to set number highlighting on first:

if !has('nvim')
    set cursorline
    set cursorlineopt=number
endif

highlight LineNR cterm=none ctermfg=Yellow ctermbg=none
highlight CursorLineNR cterm=bold ctermfg=Black ctermbg=none

Neovim behaves slightly differently in that cursorlineopt doesn't exist and set cursorline will act as set cursorline | set cursorlineopt=both in Vim.

| improve this answer | |

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.