" TimeStamp 1.13: Vim plugin for automated time stamping. " Maintainor: Gautam Iyer " Created: Fri 06 Feb 2004 02:46:27 PM CST " Last Modified: Mon 29 Mar 2004 11:00:23 AM CST " License: This file is placed in the public domain. " " Credits: Thanks to Guido Van Hoecke for writing the original " vim script "timstamp.vim". " Discription: " When a file is written, and the filename matches "timestamp_automask", " this plugin will search the first and last "timestamp_modelines" lines of " your file. If it finds the regexp "timestamp_regexp" then it will replace " it with a timestamp. The timestamp is computed by first doing a " "token_substitution" on "timestamp_rep" and passing the result to " "strftime()". See the documentation for details. " provide load control if exists("loaded_timestamp") finish endif let loaded_timestamp = 1 function s:getValue(deflt, globl, ...) " helper function to define script variables by using first any specified " global value, any non zero value from the optional parameters, and " finally if all these fail to provide a value, by using the default value if exists(a:globl) let work = "let value = " . a:globl exe work return value endif let indx = 1 while indx <= a:0 let work = "let value = a:" . indx exe work if value != "" return value endif let indx = indx + 1 endwhile return a:deflt endfunction " Default timestamp expressions let s:timestamp_regexp = s:getValue('\v\C%( 2 * l:modelines call s:subst(1, l:modelines, pat, rep) call s:subst(line('$') + 1 - l:modelines, line('$'), pat, rep) else call s:subst(1, line('$'), pat, rep) endif endfunction function s:subst(start, end, pat, rep) let lineno = a:start while lineno <= a:end let curline = getline(lineno) if match(curline, a:pat) != -1 call setline(lineno, substitute(curline, a:pat, a:rep, 'g')) endif let lineno = lineno + 1 endwhile endfunction