Monday, September 6, 2010

Re: Quick way to highlight a report file

On Mon, September 6, 2010 9:04 am, C K Kashyap wrote:
> Hi,
> I have a report file generated from a profiling tool.
> It has multiple columns(tab separated) of numbers. I wanted a way to
> highlight just the 4th column and alternate the background of each
> row.
> Is there a quick way to do it?

I think this should work:
call matchadd('WildMenu', '\_^.*\n\zs\%([^ ]* \)\{3\}\zs[^ ]* ')

(Note, that this is one line and the whitespace is an actual Tab. If copy
paste does not work, enter them as Ctrl-V (or Ctrl-Q if you are on Windows
and Ctrl-V is "insert from the Clipboard") followed by the Tab key.

I selected the WildMenu hilighting group. You can select any grou you like,
use :hi to see what different groups are available.

Depending on your definition of tab separated columns, the regular
expression might become more complex. (e.g. Quoted tabs or escaped tabs
should not count as delimiters). But this would be an excercise for later.
I like it easy, so I ignored those possibilities ;)

Hope that helps.

regards,
Christian

--
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

No comments:

Post a Comment