1

I activated a cursorline for Vim on the terminal which by default seems to underline the current line.

enter image description here

However, I would like it to be more like what the cursorcolumn looks like. Is there a way to change the appearance?

I already tried to set colors but that had no effect

1

The style of these two settings is defined by the CursorLine and CursorColumn highlight groups.

If I query these two on my Vim, I get:

:hi CursorColumn
CursorColumn   xxx term=reverse ctermbg=242 guibg=Grey40
:hi CursorLine
CursorLine     xxx term=underline cterm=underline
                   guibg=Grey40

So what we want to do is make CursorLine look more like CursorColumn.

For terminal Vim, with colors, we're most interested in the cterm group of settings (term=reverse is for B&W terminal, the gui ones are primarily for gvim.)

So one simple way is:

hi CursorLine cterm=NONE ctermbg=242

Another way forward is to "link" these styles so they look the same:

hi clear CursorLine
hi link CursorLine CursorColumn

If you also enable line numbers, you might want to look at this group:

:hi CursorLineNr
CursorLineNr   xxx term=bold cterm=underline ctermfg=11
                   gui=bold guifg=Yellow

That's the highlighting for the line numbers on the current line. You might want to have them match the background you're using for the rest of the line and disable the underlines there as well.

These might be controlled by your colorscheme, so if you set them in your vimrc you might want to do so after you set a colorscheme.

That might still not be enough if you tend to switch colorschemes or switch background from dark to light or vice-versa. To have these always apply after a colorscheme, you can also create an autocmd that sets them up after a colorscheme is loaded.

For example:

augroup cursorline
  au!
  au ColorScheme * hi clear CursorLine
               \ | hi link CursorLine CursorColumn
augroup END

You can also add any commands you decide to use for CursorLineNr to this group as well.

| 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.