1
set cursorline
highlight CursorLine cterm=underdotted ctermbg=NONE

This creates a nice dotted line under the row that my cursor is on.

  • ctermbg causes the whole row to be highlighted (which I do not want)
  • ctermfg changes the color of the underline, but also highlights the text in that color (which I do not want)

I'd like to change only the underline color (which is, when everything is unaltered, white). Is that possible?

Does anyone know how to do this?

1 Answer 1

1

The answer depends whether you use the graphical user interface or the terminal user interface.

For either UI, the underdotted attributes may not be available as descibed in :help attr-list or :help underdotted (they link to the same :help item). If a certain setting does not work, it's best to change to a configuration that's known to be working and modify step by step.

Terminal user interface

The exact outcome depends on the capabilities of your terminal emulator.

:highlight CursorLine cterm=underdotted ctermul=white 

See :help highlight-ctermul for the documentation on the color terminal underline highlight argument.

Depending on what's already set, you may have to unset additional arguments like this:

:highlight CursorLine cterm=underdotted ctermfg=NONE ctermbg=NONE ctermul=white 

Graphical user interface

For the GUI, the gui* attributes are used instead of the cterm* ones. Namely, the guisp controls the color of strikethrough and underline (apparently also underdotted but that's undocumented). See :help highlight-guisp.
The command would look like this:

:highlight CursorLine gui=underdotted guifg=NONE guibg=NONE guisp=white 

Putting it all together

To get a consistent look across TUI and GUI versions, both commands can be combined into:

:highlight CursorLine cterm=underdotted ctermfg=NONE ctermbg=NONE ctermul=white gui=underdotted guifg=NONE guibg=NONE guisp=white

Note: in my local setup, underdotted lines are not supported, neither in TUI or GUI versions. At the same time, underlines in GUI were always in guifg color. Parts of this answer are based on OP's observations.

6
  • 2
    ah! thank you. i didn't see reference to ctermul in any of my searches; it didn't work for me, but it did lead me to this (which points out the guisp option) would you mind editing your post to include that? Commented Feb 22 at 0:17
  • @AmagicalFishy based on your question, I was assuming you were using the terminal user interface. You can edit it my answer yourself. Even better - post an answer of your own! This is encouraged by this site and will help others to find your solution quickly.
    – Friedrich
    Commented Feb 22 at 10:16
  • I couldn't wait and edited my answer. Feel free to post an answer of your own anyway.
    – Friedrich
    Commented Feb 22 at 12:31
  • I am actually! I'm not sure why guisp is the one I need to use to tell you the truth Commented Feb 22 at 17:14
  • You are using the TUI version but you need to set guisp? This doesn't sound right. You might ask a new question and include the terminal emulator you use, the output of :version, a minimal vimrc to reproduce the behavior and a screenshot. However, I'm almost certain there's something in your setup we missed.
    – Friedrich
    Commented Feb 22 at 19:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.