11

While editing syntax file, I found something like:

\s*\%(\%(:\@<!\/\/.*\)\=\|\%(\/\*.*\*\/\s*\)*\)$

I'm familiar with any other than \% and \@ there. I can't even googling because I don't know what is it's name. So what it is and what it does?

statox
  • 49,782
  • 19
  • 148
  • 225
Mas Bagol
  • 527
  • 1
  • 4
  • 14

1 Answers1

15

Before googling, try the doc:

From :h \%

\%(\)   A pattern enclosed by escaped parentheses.
    Just like \(\), but without counting it as a sub-expression.  This
    allows using more groups and it's a little bit faster.
    {not in Vi}

And :h \@<!

\@<!    Matches with zero width if the preceding atom does NOT match just
    before what follows.  Thus this matches if there is no position in the
    current or previous line where the atom matches such that it ends just
    before what follows.

    Like "(?<!pattern)" in Perl, but Vim allows non-fixed-width patterns.
    The match with the preceding atom is made to end just before the match
    with what follows, thus an atom that ends in ".*" will work.
    Warning: This can be slow (because many positions need to be checked
    for a match).  Use a limit if you can, see below.

    Example         matches ~

    \(foo\)\@<!bar      any "bar" that's not in "foobar"

    \(\/\/.*\)\@<!in    "in" which is not after "//"
statox
  • 49,782
  • 19
  • 148
  • 225
  • 1
    Ah, I don't know that :help can accept pattern as argument. That's very valuable info. By the way, it does doesn't have a name, doesn't it? – Mas Bagol Aug 17 '16 at 14:04
  • 1
    It doesn't exactly accept patterns as arguments: the pattern.txt file has topics about these items thus they have an help tag associated (/\%(\) or /\%( or E53 for the first one and /\@<! for the second one) and these tags can be used as arguments of :h. Now about their name, I'd say they are called atoms just like ^ or ., but I'm not 100% sure. – statox Aug 17 '16 at 14:08
  • 5
    @statox It doesn't exactly accept patterns as arguments - Well, that's what :helpgrep is for. :) – lcd047 Aug 17 '16 at 16:03
  • @lcd047 Damn how could I have forgotten about this command?! Thanks for this helpful reminder :) – statox Aug 17 '16 at 16:14
  • 2
    This site tends to surprise me sometimes: Currently I made 170 answers and this one is the 6th most upvoted while it only contains only two easy to find quotes of the doc whereas I have other answers with vimscript code or how to realize more complex actions... I don't get why this one is so "successful" – statox Aug 18 '16 at 07:31
  • @statox Almost four years later and I'm guessing you haven't completely unraveled the mystery. Speaking for myself, I am perplexed on a regular basis by the voting patterns here. :) (Including: why don't the regulars vote for each others answers all that much? Jealousy? LOL.) – B Layer May 13 '20 at 10:58
  • @BLayer Lol Indeed there are still some weird patterns which puzzle me. I really think there is at least one bot -or a very dedicated human being- which upvotes (most) of the new answers but our other human behaviors are weird too. However, independently from the fact that regular users don't always vote for each other, I think what is important is to have a consistent voting pattern which ensure that the popularity of posts is still related to their quality and not some vote manipulations. And so far I think we are failry consistent on this topic :) – statox May 13 '20 at 11:52
  • 1
    @statox Lots of meat on this bone. :) I've considered starting a conversation in Meta on topic but there's always something else vying for my attention. We're on the same page so far, e.g. agree about votes being generally meaningful/appropriate if somewhat underwhelming w/r/t quantity and about it seeming like there's a bot (or very dedicated person!) bumping new posts. Actually, proof of a bot would be kind of depressing because that would mean a lot of my answers couldn't muster a single human being's approval. :D Cheers! – B Layer May 13 '20 at 12:04