2016-04-17 17:52 GMT+03:00 porphyry5 <gl00637@gmail.com>:
> On Saturday, April 16, 2016 at 3:48:52 PM UTC-7, Jose Caballero wrote:
>> Is it possible to highlight an entire paragraph based on a single line content?
>> I would be interested in changing the color of an entire block of
>> configuration lines if one of those lines in the block is "enabled =
>> False", for example.
>>
>> I am so new to this (*) that I am not even sure what would be the key
>> words to search for it on google.... So any tip or advice is more than
>> welcome.
>>
>> What is a "paragraph"? Also what exactly you mean by "highlight",
>>
>>
>>
>>
>>
>> Fair questions, I guess. I will try to be more clear.
>>
>>
>> I would like to have a VIM syntax file that changes the color or entire paragraphs (a set of lines between two blank lines) if one of the lines in the paragraph matches pattern
>> "enabled = False".
>>
>>
>> I hope now I explained myself better.
>>
>>
>> Jose
>
> If you use search hilighting this might do what you want
> /\n\(.*\n\)\{-}.*enabled = False.*\n\(.*\n\)\{-}\n
It will not.
1. I did mess up with \@= and \@<= for a reason. Without them regex
will not highlight successive matches.
2. It does not highlight an entire paragraph *ever*. \n\(.*\n\) does
*not* match *only* at the empty line. It matches everywhere where
there are two successive lines.
3. First \{-} does *not* work like you think. In
foo
enabled = True
enabled = False
bar
test
it will highlight starting from the EOL at the first line till EOL
just below bar. Engine captures the first place where \n matches tries
to match the following \(…\)\{-} as less times as possible, then
proceeds with the rest of the pattern. If matching succeeds it has
absolutely no reason to retry from the other place where \n matches
just to make sure \(…\)\{-} is matched even less times.
4. Your regex does not work for sections which are placed at the end
of the file.
5. Your regex works for sections which are placed at the beginning of
the file only because of 2. But it will not work if `enabled = False`
is the very first line in the file.
>
> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Sunday, April 17, 2016
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment