" DNS Serial Incrementer " Author: Folke Ashberg <folke@ashberg.de> " Copyright: 2001 by Folke Ashberg " LAST MODIFICATION: Fre Sep 14 19:05:32 CEST 2001 " CVS: $Id: dnstools.vim,v 1.4 2002/08/15 11:08:15 folke Exp $ " Usage: " Serial Updater: " Just execute the command DNSserial and this tiny script " will increment the serial number, preserving that style you use :) function DNS_getnum(oldnum) let oldnum = a:oldnum if oldnum < 19700101 " 1, 2, 3 style let retval = oldnum + 1 elseif oldnum < 1970010100 " YYYYMMDD style let dateser = strftime("%Y%m%d") if dateser > oldnum let retval = dateser else let retval = oldnum + 1 endif else " YYYYMMDDNN style let dateser = strftime("%Y%m%d00") if dateser > oldnum let retval = dateser else let retval = oldnum + 1 endif endif return retval endfun function DNSserial() let restore_position_excmd = line('.').'normal! '.virtcol('.').'|' let oldignorecase = &ignorecase set ignorecase " substitute now ( there's a bug in VIM's vi Syntax :( ) " silent %s/\(soa[[:space:]]\+[a-z0-9.-]\+[[:space:]]\+[a-z0-9.-]\+[[:space:]]*(\?[\n\t ]*\)\([0-9]\+\)/\=submatch(1) . DNS_getnum( submatch(2) )/ " restore position exe restore_position_excmd " disable hls if 1 == &hls noh else set hls endif " restore old case behave let &ignorecase=oldignorecase endfun command DNSserial :call DNSserial()