syn match vs. syn keyword

73 views
Skip to first unread message

Andy Lester

unread,
Jun 5, 2013, 5:39:42 PM6/5/13
to vim-...@googlegroups.com, Hinrik Örn Sigurðsson
Back in commit b34f2e6e I merged in a bunch of Hinrik Örn Sigurðsson's changes to the main vim-perl project.  One big part of that was switching from using "syn keyword" to "syn match" for identifying Perl keywords.

Can anyone (Hinrik, the list) tell me the reason for doing this?  Was there a benefit to using syn match?  I want to revert to syn keyword for simplicity and speed's sake, but I'm wary of doing so without knowing why the change was made.

I'm tracking this at https://github.com/vim-perl/vim-perl/issues/119

Thanks,
xoa

Benjamin Fritz

unread,
Jun 7, 2013, 4:28:50 PM6/7/13
to vim-...@googlegroups.com, Hinrik Örn Sigurðsson
On Wed, Jun 5, 2013 at 4:39 PM, Andy Lester <an...@petdance.com> wrote:
> Back in commit b34f2e6e I merged in a bunch of Hinrik Örn Sigurðsson's
> changes to the main vim-perl project. One big part of that was switching
> from using "syn keyword" to "syn match" for identifying Perl keywords.
>
> Can anyone (Hinrik, the list) tell me the reason for doing this? Was there
> a benefit to using syn match?

I don't know if this was the reason, but in general keyword can be bad
for anyone trying to extend an existing syntax, because:

1. It always takes precedence over match or region items, even if the
match or region is defined last.
2. It cannot contain any other items.

From the help:

5. Defining a syntax *:syn-define* *E410*

Vim understands three types of syntax items:

1. Keyword
It can only contain keyword characters, according to the 'iskeyword'
option. It cannot contain other syntax items.

and

PRIORITY *:syn-priority*

When several syntax items may match, these rules are used:

1. When multiple Match or Region items start in the same position, the item
defined last has priority.
2. A Keyword has priority over Match and Region items.
3. An item that starts in an earlier position has priority over items that
start in later positions.

Hinrik Örn Sigurðsson

unread,
Jun 8, 2013, 4:25:22 PM6/8/13
to Benjamin Fritz, vim-...@googlegroups.com
Yeah, I clearly remember running into the limitations of using
`keyword` over `match`. Though I suspect this (probably very useful)
change was done my Lukas Mai. My changes were mostly centered on the
Perl 6 syntax file.

Andy Lester

unread,
Jun 11, 2013, 5:29:52 PM6/11/13
to vim-...@googlegroups.com, Benjamin Fritz

On Jun 8, 2013, at 3:25 PM, Hinrik Örn Sigurðsson <hinri...@gmail.com> wrote:

Yeah, I clearly remember running into the limitations of using
`keyword` over `match`.

Thanks for the history lesson.  I'm abandoning the "syn keyword" branch.
Reply all
Reply to author
Forward
0 new messages