vim: how to display a "cross through" line on the text?

1,150 views
Skip to first unread message

ping

unread,
Nov 15, 2012, 10:02:30 PM11/15/12
to Vim.use.G
I know vim is an "pure text" editor, not word or rendering system.
but currently I have it displaying the bold, italic, underline with an
asciidoc syntax highlight file.
https://github.com/dagwieers/asciidoc-vim

it is surprisingly good in terms of displaying effect and asciidoc
syntax compliance.

only thing is it is VERY slow sometime when you jump back and forth. but
that is another issue.
here I'm talking about the word displaying effect -- I'm still curious
how can this pure text editor display the a underline under each
charactor, but it works.

anyway, if the underline is OK, how about a "cross-through" line?

Christian Brabandt

unread,
Nov 16, 2012, 1:26:16 AM11/16/12
to vim...@googlegroups.com
On Fri, November 16, 2012 04:02, ping wrote:
> I know vim is an "pure text" editor, not word or rendering system.
> but currently I have it displaying the bold, italic, underline with an
> asciidoc syntax highlight file.
> https://github.com/dagwieers/asciidoc-vim

This syntax script has some nasty side effects like remapping some keys.
That is at least unexpected and should never happen in a syntax script
but belongs into a filetype plugin.

>
> it is surprisingly good in terms of displaying effect and asciidoc
> syntax compliance.
>
> only thing is it is VERY slow sometime when you jump back and forth. but
> that is another issue.
> here I'm talking about the word displaying effect -- I'm still curious
> how can this pure text editor display the a underline under each
> charactor, but it works.

It's a syntax property. Read :h attr-list to see, what is possible.

> anyway, if the underline is OK, how about a "cross-through" line?

Not possible with syntax matching.

regards,
Christian

Tony Mechelynck

unread,
Nov 16, 2012, 2:47:04 AM11/16/12
to vim...@googlegroups.com, ping
Short answer: You can't.

Long answer: Gvim knows about 16777216 background colours, 16777216
foreground colours, as many different characters as are possible with
Unicode, bold, italic and underline in the foreground colour, and
16777216 additional colours for curly underline.

When running in a terminal, Vim is limited by what the terminal can do.
This usually reduces the number of different colours, suppresses curly
underline, and, depending on the terminal, may suppress italic and/or
ordinary underline, and may make boldface no different from some
"brighter" foreground colour. It may also reduce the number of different
glyphs effectively displayable.

Neither gvim nor Console Vim can display strike-through, except by
modifying the text by adding U+0336 COMBINING LONG STROKE OVERLAY after
each character � but this is a text change, not a highlighting effect,
so you cannot do it as a syntax highlight. If you could, it would
probably already be used in the syntax/html.vim script for the <s> and
<strike> (and maybe <del>) elements.

What you might do, at the cost of spell checking, is use for instance
:hi StrikeOut gui=undercurl guisp=fg
to add a curly underline in the default foreground colour to represent
overstrike (but only in gvim, not in Vim in a terminal).


Best regards,
Tony.
--
You are only young once, but you can stay immature indefinitely.

Jürgen Krämer

unread,
Nov 16, 2012, 3:54:31 AM11/16/12
to vim...@googlegroups.com

Hi
as others have already written there is no general way (e.g., by means
of a pre-defined attribute for :highlight), but at least on Windows you
could use the font attribute of :highlight

:hi asciidocDeleted font=Consolas:s

in the GUI version.

Note the ":s" after the font name. Something similar might be possible
with X11 font names, too, but I am absolutely clueless in this area.

If you define the font this way, make sure it matches the font set with
the 'guifont' option. Otherwise you might run into display problems
because of different character widths.

Regards,
J�rgen

--
Sometimes I think the surest sign that intelligent life exists elsewhere
in the universe is that none of it has tried to contact us. (Calvin)
Reply all
Reply to author
Forward
0 new messages