Sunday, January 30, 2011

Re: Substitute within a highlight group.

On 01/28/2011 07:27 PM, David Fishburn wrote:

> SRSearch optionally takes parameters.
Oh.

I'v already done without srhg.

May be it will be usefull for someone. This function finds DNS zone
serial and
increments it.

function AdjustSerial()
let l:pos = getpos( '.' )
call cursor( 1, 1 )
while search( '\D\zs\d', 'W' ) > 0
if synIDattr( synID( line('.'), col('.'), 1 ), 'name' )
\ == 'zoneSerial'
s/\(\d\+\)/\=IncSerial( submatch( 1 ) )/
break
endif
endwhile
call setpos( '.', l:pos )
endfunction
function IncSerial( s )
let l:today = strftime( "%Y%m%d", localtime() )
if match( a:s, '^' . l:today ) == 0
return str2nr( a:s ) + 1
else
return l:today . '01'
endif
endfunction

--
sergio.

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