Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 714
Codemonkey Avatar asked Nov 26 '15 11:11

Codemonkey


People also ask

How do I underline text in Vim?

Assuming that you want to edit the text file to underline a heading or similar. You can do this by duplicating the line using y y ] p (or :t . <CR> ) and replacing the text with hyphens with a :substitute command like :s!\ S!-!

How do I highlight a specific line in Vim?

With the default backslash leader key, pressing \l will highlight the line that currently contains the cursor. The mapping also sets mark l so you can type 'l to return to the highlighted line.

Why are some words highlighted in vim?

Most filetypes (like python) in Vim come with a syntax that defines highlight groups (see them via :highlight ). A colorscheme then provides combinations of foreground / background color and/or formatting like bold and italic, for terminals, color terminals, and/or GVIM.

How to move the highlight of a line in Vim?

Highlighting that moves with the cursor. Simply putting :set cursorline in your vimrc will highlight the current line in every window and update the highlight as the cursor moves. The following example shows how to change the highlight colors and how to create a mapping to toggle cursorline (to highlight the current line) and cursorcolumn ...

How to activate a vertical line at the cursor's location in Vim?

The following command in Vim activates a vertical line at the cursor's location. to toggle (with the exclamation mark, works with all set-command) set cursorcolumn! set cursorline set cursorline! hi CursorLine ctermbg=235 *#defines a gray colour for the horizontal line*

How to highlight the corresponding column in vimrc?

You can highlight the corresponding column as well, using the command: It is useful to toggle highlighting on and off by pressing one key in the editor. Add these line to your vimrc: typing 'H' will toggle highlighting on and off (Map it to another key if you want)

How do I restore the cursorline highlight in Vim?

This is restored during program startup through session restoration. However, since the session restoration is typically done after .vimrc has been run (typically using a function invoked through 'autocmd VimEnter *'), the cursorline highlight setting in .vimrc is reset by the default for the restored colorscheme.


2 Answers

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.

like image 141
Kent Avatar answered Nov 15 '22 23:11

Kent


:set cursorline

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

like image 20
Pipo Avatar answered Nov 16 '22 00:11

Pipo