On 11/19/2010 09:55 PM, [email protected] wrote:
Is it possible to search/highlight line-pairs (a pair with "NameOfParameter" only differing in "l-" and "r-") which absolute values differ (ignoring again the first column)?For example: setup l-NameOfAParameter 0.5 setup r-NameOfAParameter -0.5 intro l-NameOfAnotherParameter 2.71818281 intro r-NameOfAnotherParameter 3.14159259 Line 3 and 4 will be found/highlighted then.
I'm not sure it's easy to highlight those that *differ* in absolute-value, but you could do a little jiggery to find those that are the *same* in absolute value and make them dimmed. Something like this (untested)
:match Comment /^\(\w\+\s\+\)l\(-\w\+\)\s\+\(\d\+\.\d\+\)\n\1r\2\s\+-\3$/
This assumes that the positive value always proceeds the negative value. If that can be inverted, you might have to do two checks:
:2match Comment /^\(\w\+\s\+\)l\(-\w\+\)\s\+-\(\d\+\.\d\+\)\n\1r\2\s\+\3$/
to catch the other cases (just moving the "-" before the 3rd capture group, and out from before the 3rd capture-group-instance (the \3). If you were feeling ambitious, this could be combined with a little obscurity, but unless you need it, I'd just use both ":match" and ":2match" for this.
The first capture group snags the "setup<whitespace>". It then requires-but-ignores the "l" prefix. The second capture group snags the "-NameOfAParameter". Some whitespace is required-but-ignored. It then captures the positive decimal number (tweak the "\d\+\.\d\+" if the decimal portion is optional and you can have integers or scientific-notation in this field) as the 3rd capture group.
Once it has the bits from the first line, it then requires a newline, the 1st match, the "r"-prefix, the 2nd match, some whitespace, a minus sign and the 3rd match (the number). Reword accordingly for the "negative-comes-before-positive" version.
By using "Comment" as the highlight type, that's usually a more subdued color in most of my color-schemes (in my case, dark-gray-on-black) so the cases you're interested in should pop out.
Hope this helps. -tim -- 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
