On 4/9/07, Ian Tegebo <[EMAIL PROTECTED]> wrote:
On 4/9/07, Nikolai Weibull <[EMAIL PROTECTED]> wrote:

>   ^ \{3\}[a-z][a-z ]*[a-z]$
I hope nobody minds if I take this opportunity to ask a question about
vim's pattern matching.

After reading |pattern| I wonder if the following is more efficient:

syn match manSubHeading '^ \{3\}\l\l\?\l$'

Yes, and it may be more correct as well, at least in the first and
last instance.  However, the second part may also contain a space, so
\l isn't correct there; and I don't know where you get that \? from.
This is the correct pattern:

 ^ \{3}\l[[:alpha:] ]*\l$

(I also noticed that the apparently accepted "\{m\}" is being used in
this file instead of the documented "\{m}")

One can of course ask oneself if a subsection heading must consist of
at least two letters.  I'm guessing that the intent was to force the
line to end with a non-space:

 ^ \{3}\l\%([[:alpha:] ]*\l\)\=$

In fact, I'd prefer it be written as

 ^ \{3}\a\%([[:alpha:] ]*\a\)\=$

as 'syn case ignore' is on, \l and \a will be the same.  However, \a
meshes better with [:alpha:] and may, depending on how all this is
implemented, be a miniscule amount faster.

Taken from |pattern|:

        - Matching with a collection can be slow, because each character in
          the text has to be compared with each character in the collection.
          Use one of the other atoms above when possible.  Example: "\d" is
          much faster than "[0-9]" and matches the same characters

Do people find this to make a different for moderate file sizes, e.g.
the man page for 'less' being ~2000 lines?

Probably not.

 nikolai

Reply via email to