Syntax keepend/oneline vs. extend

13 views
Skip to first unread message

Rob Foehl

unread,
Feb 11, 2023, 3:52:33 AM2/11/23
to vim...@googlegroups.com
Quoting the help for :syn-extend :

The "keepend" behavior can be changed by using the "extend" argument.
When an item with "extend" is contained in an item that uses
"keepend", the "keepend" is ignored and the containing region will be
extended.

Fair enough, but how does one get the opposite behavior? I.e. what I want
is "keepend-but-seriously-stop-here" regardless of whether contained items
use extend, or match the newlines, etc.

(Context: including portions of one syntax in another, where the former's
use of extend doesn't anticipate the latter. I haven't found any
obviously right way to do this in either the help or the runtime files
that ship with Vim, only workarounds for specific cases.)

-Rob

Rob Foehl

unread,
Feb 26, 2023, 11:30:42 PM2/26/23
to vim...@googlegroups.com
On Sat, 11 Feb 2023, Rob Foehl wrote:

> (Context: including portions of one syntax in another, where the former's use
> of extend doesn't anticipate the latter. I haven't found any obviously right
> way to do this in either the help or the runtime files that ship with Vim,
> only workarounds for specific cases.)

Toying with this a bit more, I managed to work around the issues with
extend by mechanically collecting :syn list output and replacing the
offending bits of the existing syntax, which is... ugly.

The seeming inability to do this otherwise had me wondering why this
problem wasn't more commonplace, and how often extend is actually used in
the syntax files shipped with Vim (as of 9.0.1307):

99 syntax/perl.vim
23 syntax/plsql.vim
22 syntax/php.vim
18 syntax/rpl.vim
14 syntax/fortran.vim
11 syntax/raku.vim
10 syntax/c.vim
8 syntax/rhelp.vim
7 syntax/baan.vim syntax/rib.vim syntax/tt2.vim
6 syntax/cs.vim
4 syntax/ada.vim syntax/pike.vim syntax/xml.vim
3 syntax/obse.vim syntax/typescriptreact.vim
2 [12 files]
1 [14 files]
0 [636 files]

Oh. Of course the one I'm trying to embed is the outlier... Jokes about
only Perl being able to parse Perl aside, am I wrong to presume that at
least a few of those 99 instances might be gratuitous?

Among the dozen or so that I've tripped over thus far, I can't tell what
any of them were actually intended to accomplish. For example:

syn match perlComment "#.*" contains=perlTodo,@Spell extend

Huh? EOL is also end-of-comment, so what's that supposed to do?

-Rob
Reply all
Reply to author
Forward
0 new messages