Search code examples
vim

How to underline (rather than highlight) the current line in vim?


I believe it's possible to get an underline under the current line, rather than a highlight.

This adds the highlight in my .vimrc:

set cursorline

This is what I've tried adding to get an underline:

:highlight CursorLine gui=underline cterm=underline

But it appears to make no difference.

I'm using vim 7.4.629 on Centos 6.7 through putty, if that helps.


Solution

  • try :hi clear CursorLine to clear the current cusorline hl, then :hi CursorLine gui=underline cterm=underline

    The color of underline is same as your ctermfg or guifg. You can either live with your "colorful" underline, or add cterm/guifg to make the underlined text and the underline same color.

    Additional info

    To only highlight the cursor line when in insert mode

    au InsertEnter * set cul
    au InsertLeave * set nocul
    

    Copied from another anser by @meteowrite