Codemonkey
Codemonkey

Reputation: 4809

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.

Upvotes: 27

Views: 33790

Answers (3)

Kent
Kent

Reputation: 195169

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

Upvotes: 30

meteowrite
meteowrite

Reputation: 43

For me it works best to highlight the cursor line only in Insert mode. To do so, I use the action snippet to activate cursor underlining (full line) whenever Insert mode is activated and later deactivating it upon leaving the mode.

au InsertEnter * set cul
au InsertLeave * set nocul

Upvotes: 2

Pipo
Pipo

Reputation: 5093

:set cursorline

was the best solution for me, you can combine it with removing the cursorLine as the answer above mentions

Upvotes: 4

Related Questions