inte
  integ
  intege
  integer
  inter
  interv
  interva
  interval

is there any easy way to make these two commands work?

  syntax match Error /int\%[eger]/
  syntax match Error /int\%[erval]/

The second match begins taking priority as soon as the word is 'inte', and
prevents 'integer' from being matched correctly.

Your problem is that both patterns match int and inte, resulting in ambiguity.
I think solution is to separate 'int' and 'inte' as separate matches,
whcih results in unambiguous matching:

   syntax match Error /integ\%[er]/
   syntax match Error /inter\%[val]/
   syntax match Error /\<int\%[e]\>/

(untested)


I suspect, in testing ideas on this, I may have turned up a bug
in either the implementation of \%[] or its documentation needs a
remedy.

In theory, the following should work:

        :match Error /int\%[\(eger\|erval\)]/

I base that assumption on a combination of these two pieces of
the help:

 From ":help /\%[]" one finds that this syntax matches "a list of
optionally matched atoms." (note "atoms", not "ordinary atoms")

So what's an atom?  We jump over to ":help atom" where we read
that an atom is

     atom    ::=            ordinary-atom               |/ordinary-atom|
                or  \( pattern \)               |/\(|
                or  \%( pattern \)              |/\%(|
                or  \z( pattern \)              |/\z(|

and that a pattern is (according to ":help pattern")

    pattern ::=     branch
                or  branch \| branch
                or  branch \| branch \| branch
                etc.

Thus, my understanding of it is that one should be perfectly
allowed to use a \(...\|...\) "atom" within a \%[] expression.
If this is not the case, the help for \%[] may likely intend to
refer to "ordinary atoms" rather than "atoms".

*However*, the above search/match expression returns an "E369:
invalid item in \%[]" error.

I get this both in vim6.3 and vim7.

-tim






Reply via email to