[vim/vim] Dotted/dashed underline support (Issue #9553)

62 views
Skip to first unread message

Joseph Adams

unread,
Jan 18, 2022, 8:50:25 AM1/18/22
to vim/vim, Subscribed

At the moment Vim supports the 'standard' and curly underline styles as term, cterm or gui attributes.

With mintty, wezterm and (soon) kitty supporting all five underline styles (i.e. standard, double, curly, dotted and dashed), it would be great if Vim would add support for using the relevant escape codes. Here's an example of what the different underline styles currently look like (taken from kitty):

image

Adding different underline styles would enable (besides using colouring) to, say, differentiate between multiple kinds of error/linter/suggestions messages that use a highlight group to denote the relevant code passage. Also it would encourage other terminals (like here previously) to implement the additional escape codes.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.
You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553@github.com>

Bram Moolenaar

unread,
Jan 18, 2022, 11:37:29 AM1/18/22
to vim/vim, Subscribed

The double underline looks like a thin underline, is that a display error?

Do all the terminals use the same escape codes? And what are they?


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1015590997@github.com>

Joseph Adams

unread,
Jan 19, 2022, 6:03:41 AM1/19/22
to vim/vim, Subscribed

The double underline looks like a thin underline, is that a display error?

That's just in the image, the double underline is more pronounced in the terminal.

Do all the terminals use the same escape codes? And what are they?

They do indeed! The SGR escape code extension was proposed by the author of kitty (and later modified by the authors of mintty (selecting which exact escape code would actually map to which behavior). A description can be found in the kitty documentation, which I'll also copy here for convenience: (note: on the website it still says some are not implemented, that is because a new version of kitty hasn't been released yet)

<ESC>[4:0m  # this is no underline
<ESC>[4:1m  # this is a straight underline
<ESC>[4:2m  # this is a double underline
<ESC>[4:3m  # this is a curly underline
<ESC>[4:4m  # this is a dotted underline
<ESC>[4:5m  # this is a dashed underline
<ESC>[4m    # this is a straight underline (for backwards compat)
<ESC>[24m   # this is no underline (for backwards compat)

So far, Vim supports no underline, straight underline, and curly underline (well, technically you can use any, by just setting t_Ce, t_Cs and the like to values you want, but that's besides the point).

For any bystanders wanting to try this, here's some bash that should render as in the screenshot above, if your terminal emulator supports the corresponding underline styles:

printf '\e[4:1mHello, underline!\n\e[m\e[4:2mHello, double-underline!\n\e[m\e[4:3mHello, under-curl!\n\e[m\e[4:4mHello, under-dotted!\n\e[m\e[4:5mHello, under-dashed!\n\e[m'


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016337081@github.com>

Dominique Pellé

unread,
Jan 19, 2022, 7:10:42 AM1/19/22
to vim/vim, Subscribed

@brammool wrote:

The double underline looks like a thin underline, is that a display error?

Do all the terminals use the same escape codes? And what are they?

For me, using xfce4-terminal-0.8.7.4 on xubuntu-18.04.6 (so a bit ancient),
double underline works in the terminal as illustrated in the screenshot below.
But dotted and dashed underline shows nothing.

double-underline-et-with-xfce4-terminal-0 8 7 4


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016406376@github.com>

Maxim Kim

unread,
Jan 19, 2022, 7:14:20 AM1/19/22
to vim_dev
On wsltty (windows) everything is rendered:

2022-01-19_15-14-58.png
среда, 19 января 2022 г. в 15:10:42 UTC+3, Dominique Pellé:

Dominique Pellé

unread,
Jan 19, 2022, 7:20:34 AM1/19/22
to vim/vim, Subscribed

I also tried on a xubuntu-20.04.3 machine with xfce4-terminal-0.8.9.1 and the dotted and dashed appear like under-curl.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016413631@github.com>

Joseph Adams

unread,
Jan 19, 2022, 7:27:11 AM1/19/22
to vim/vim, Subscribed

@dpelle Yeah, xfce4-terminal uses libvte, which doesn't support dotted/dashed underline styles (yet, I suppose). The culprit is in this switch statement where one could add cases 4 and 5 for the additional underline styles. (A nice thing is: it seems one wouldn't have to fight with the underline styles being drawn on a per glyph basis, as in the case of kitty.)


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016418566@github.com>

Bram Moolenaar

unread,
Jan 19, 2022, 8:00:34 AM1/19/22
to vim/vim, Subscribed


> > The double underline looks like a thin underline, is that a display error?
>
> That's just in the image, the double underline is more pronounced in
> the terminal.
>
> > Do all the terminals use the same escape codes? And what are they?
>
> They do indeed! The SGR escape code extension was proposed by the author of kitty (and later modified by the authors of mintty (selecting which exact escape code would actually map to which behavior). A description can be found [in the kitty documentation](https://sw.kovidgoyal.net/kitty/underlines/), which I'll also copy here for convenience: (note: on the website it still says some are not implemented, that is because a new version of kitty hasn't been released yet)

>
> ```
> <ESC>[4:0m # this is no underline
> <ESC>[4:1m # this is a straight underline
> <ESC>[4:2m # this is a double underline
> <ESC>[4:3m # this is a curly underline
> <ESC>[4:4m # this is a dotted underline
> <ESC>[4:5m # this is a dashed underline
> <ESC>[4m # this is a straight underline (for backwards compat)
> <ESC>[24m # this is no underline (for backwards compat)
> ```

I think the old way of ending underline is with <Esc>[m.


> So far, Vim supports no underline, straight underline, and curly
> underline (well, technically you can use any, by just setting `t_Ce`,
> `t_Cs` and the like to values you want, but that's besides the point).

>
> For any bystanders wanting to try this, here's some bash that should
> render as in the screenshot above, if your terminal emulator supports
> the corresponding underline styles:
>
> ```bash

> printf '\e[4:1mHello, underline!\n\e[m\e[4:2mHello, double-underline!\n\e[m\e[4:3mHello, under-curl!\n\e[m\e[4:4mHello, under-dotted!\n\e[m\e[4:5mHello, under-dashed!\n\e[m'
> ```

Currently t_us is used for normal underline and t_Cs for undercurl
start. We could use t_Ds for dotted start, t_Us for double underline
start. Not sure what to use for dashed, why do all of these start with
"d"? :-)

--
5 out of 4 people have trouble with fractions.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016442383@github.com>

Joseph Adams

unread,
Jan 19, 2022, 8:13:27 AM1/19/22
to vim/vim, Subscribed

I think the old way of ending underline is with [m.

Indeed, you are right. In one of my previous comments I also use \e[m to reset the underline style after every printed line. To the best of my knowledge all the terminal emulators that support the 'fancy' underline style also support both the old and new (\e[4:0) way of resetting the underline style. So there's no need to change anything about how the reset works.

Currently t_us is used for normal underline and t_Cs for undercurl
start. We could use t_Ds for dotted start, t_Us for double underline
start. Not sure what to use for dashed, why do all of these start with
"d"? :-)

It is quite an annoyance, yes :D I would propose the following:

t_ue/t_Ce --> no underline (in my vimrc both are mapped to \e[m)
t_us --> straight underline
t_Us --> double underline
t_Cs --> curly underline
t_ds --> dotted underline
t_Ds --> dashed underline

It's certainly not ideal, but I like the lower- to uppercase progression meaning a more pronounced version (a double vs single underline and a dashed vs dotted underline). Curly is just an exception. But I'm also open for other suggestions, as the Vim-internal names for the escape code mappings are virtually irrelevant.


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1016452719@github.com>

Kovid Goyal

unread,
Jan 19, 2022, 10:00:25 PM1/19/22
to vim/vim, Subscribed

I think the old way of ending underline is with [m.

[m is equivalent to [0m and that clears all formatting. If you want to clear only underline formatting, you use either 4:0m or 24m


Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1017071508@github.com>

Bram Moolenaar

unread,
Jun 29, 2022, 1:40:01 PM6/29/22
to vim/vim, Subscribed

Closed #9553 as completed via 84f5463.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issue/9553/issue_event/6904490604@github.com>

Bram Moolenaar

unread,
Jun 29, 2022, 1:47:55 PM6/29/22
to vim/vim, Subscribed

This has been implemented. Please try it out and let us know if something doesn't work.


Reply to this email directly, view it on GitHub.

You are receiving this because you are subscribed to this thread.Message ID: <vim/vim/issues/9553/1170295557@github.com>

Reply all
Reply to author
Forward
0 new messages