Tuesday, September 1, 2009

Re: Applying highlighting matches to second column only?

> I'm trying to highlight specific letters in words in a specific column.
> I have a file looking like this
>
> word_1 long_word_1
> word_2 long_word_2
> word_3 long_word_3
> ...
>
> where word_n are all different and of varying (or equal) length, and
> long_word_n are all different but of the same length. word_n and
> long_word_n are separated by white space.
>
> I want to highlight every letter, e.g., 'A', in long_word_n, but not in
> word_n.
>
> Question: How do I limit my match to apply to only the second column?
>
> My current code (below) is too greedy -- the match is on every
> occurrence of A (or a) in each line.
>
> Current code:
>
> syn match myA "[Aa]\+"
> highlight myA guifg=black guibg=yellow

You might try using the pattern

\(^\w*\s\+\w*\)\@<=[Aa]

as in

syn match myA "\(^\w*\s\+\w*\)\@<=[aA]"

which seems to do what you describe.

-tim


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

No comments:

Post a Comment