Friday, December 31, 2010

Re: Substitute within a highlight group.

Hi sergio!

On Fr, 31 Dez 2010, sergio wrote:

> 2)
> % vim bindzone
> :source incoming/srhg/plugin/SrchRplcHiGrp.vim
> <GOTO zone serial>
> :SRChooseHiGrp
> SRHiGrp - Group ID: 97 Name: zoneSerial
> :SRHiGrp '\(.*\)','__\1__'
> .* also includes comment, that exists on this line: so I get:
> __2007031901 ; serial__
> instead of:
> __2007031901__ ; serial

Without having used the mentioned script, I would probably use something
like this:
:%s/\<\d\+\>/\=synIDattr(synID(line('.'),col('.'),1),'name')=~'zoneSerial?'__'.submatch(1).'__':submatch(1)/g
(one line)

As you can see, I made the regex more strict, since .* will probably
always match a whole line and could obviously be part of several
different syntax items.

If you need this more often, this can probably be scripted or put into
functions for easier use.

> 3)
> <GOTO ip address>
> :SRChooseHiGrp
> SRHiGrp - Group ID: 94 Name: zoneIPAddr
> :SRSearch
> goes to the next octet of selected ip address, not to the next ip address.
>
> <GOTO zoneDirective>
> :SRChooseHiGrp
> SRHiGrp - Group ID: 89 Name: zoneDirective
> :SRSearch
> first SRSearch (from neutral space) goes to '$' of next directive,
> second --- to the first letter after $ of the same directive.

Don't understand, what you are trying to do here.

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