Gary Johnson
unread,Jul 25, 2017, 2:47:41 PM7/25/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Sign in to report message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to vim...@googlegroups.com
I discovered an odd syntax highlighting problem while working on
a syntax plugin. I am trying to highlight single-line or multi-line
strings as group String and highlight any characters in strings
after the 'textwidth' column as group Error. The following simple
example demonstrates the problem.
Here are the two example files, foo.vim and foo.txt.
----------------------------- foo.vim -----------------------------
set textwidth=21
syntax enable
syn region fooString start=+"+ skip=+\\\\\|\\"+ end=+"+ keepend
syn match fooError /\%>21v.*/ containedin=fooString
hi def link fooString String
hi def link fooError Error
----------------------------- foo.txt -----------------------------
"Mary had a little lamb,
Its fleece was white
as snow."
-------------------------------------------------------------------
Here is the example command.
$ vim -N -u NONE -i NONE -c 'so foo.vim' foo.txt
The first line of foo.txt is 24 characters long, so the last three
characters (mb,) are highlighted as fooError as expected. The
second line is exactly 21 characters, so it is highlighted only as
fooString, again as expected. However, all of the third line is
highlighted as fooError. If the length of the second line is
increased or decreased at all, the third line becomes highlighted as
fooString as it should.
This looks like a bug to me.
I am using Vim 8.0.691 in a terminal on Linux. I haven't updated to
the latest version because I am trying to avoid the terminal feature
thrash.
Regards,
Gary