*timestamp.vim* Plugin for automated time stamping Description:~ 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()|. The plugin tries to stay out of your way, and make the change as transparent as possible. All your history (search, command, etc) and jumplists are unaltered, except the undo history (which contains an additional change). All the default variables and actions can be changed by buffer / global vim variables. See |timestamp_examples| for two simple examples. The plugin and its documentation file can be installed as described under |add-global-plugin| and |add-local-help|. Do not forget to run |:helptags|. ------------------------------------------------------------------------------ Options and Specifications:~ 1. Timestamp Regexp format: *timestamp_regexp* If the regexp |timestamp_regexp| is found in the first and last |timestamp_modelines| lines of your file it is replaced by a timestamp (see |timestamp_rep|). Default: '\v\C%( Created: TIMESTAMP Last Modified: TIMESTAMP When you first write the file, these lines will change to: > Created: Thu 26 Feb 2004 03:15:54 PM CST Last Modified: Thu 26 Feb 2004 03:16:02 PM CST On subsequent writes of the file, the first line will remain unchanged and the second will be stamped with the time of writing. NOTE: If you find that on subsequent writes of the file, the second line is also unchanged, it is probably because the time returned by strftime is NOT is the format above. [Look closely and see if there is a leading 0 or timezone missing]. If you are using version 1.11 and higher and still have this problem, please report it to me. As a temporary fix, you can put the line > let timestamp_regexp = '\v\C%( :let g:timestamp_automask = "*.html" to limit timestamping to html files. NOTE: This global variable has to be set BEFORE the plugin is loaded. ------------------------------------------------------------------------------ 5. timestamp_modelines *timestamp_modelines* The number of lines searched for the |timestamp_regexp| is controlled by the |timestamp_modelines| variable. By default this will be equal to the 'modelines' option. To specify a different value, set the global vim variable 'g:timestamp_modelines'. NOTE: This global variable has to be set BEFORE the plugin is loaded. If this is set to to '%' all lines in the file will be searched for the regexp |timestamp_regexp|. NOTE: This may be more than you want. ------------------------------------------------------------------------------ 6. Examples: *timestamp_examples* 1. No case matching, short format timestamps: > let g:timestamp_regexp = '\v\c%(last %(changed?|modified):\s+)@<=\d{4} \a{3} \d{2}' let g:timestamp_rep = '%Y %b %d' < Result: > " Last change: 2004 Feb 26 < 2. Match case, with filename, username and hostname in html comments: > let g:timestamp_automask = '*.html' let g:timestamp_regexp = '\v\C%(\ ------------------------------------------------------------------------------ 7. Change History *timestamp_history* Version 1.13:~ Removed unwanted code for preserving cursor location. With use of setline and getline this is no longer necessary. A bug caused timestamp.vim to make changes in all lines in the |timestamp_modelines| range. Corrected the code so that now changes are made only when there is a timestamp in a particular line. This makes undoing changes a lot easier. Version 1.12:~ Some Micro$oft machines don't support the timezone ('%Z'). Made the timezone optional in the default settings. The script (with default settings) should now work on both Linux / Window$ machines. Thanks to Krall Ed-P27726 for testing this. Version 1.11:~ Minor bug fix. The format of strftime("%c") is not standard among all systems / locales. Changed the default value of "timestamp_rep" from "%c" to the full expanded version. This should be more robust. Version 1.1:~ Does not modify any marks or the search history list. Tries to make timestamping as "transparent" as possible. Version 1.0:~ Original fork of "timstamp.vim". See |timestamp_differences| for a list of differences. ------------------------------------------------------------------------------ 8. Differences From Timstamp: *timestamp_differences* This script is based on "timstamp.vim" originally written by Guido Van Hoecke . There are many differences: 1. Note the extra E in the name (timEstamp). 2. Some bug fixes. 3. Splits the pattern and replacement into two separate variables. 4. Allows buffer local variables to replace the timestamp controls. 5. Removed support for multiple timestamps (I thought this was wasteful, besides allowing buffer local variables to control timestamps makes this unnecessary. Timestamps for particular filetypes can be set by buffer local variables in filetype plugins) 6. timstamp_* variables are no longer present. Use |timestamp_regexp| for the search pattern, and |timestamp_rep| for the replacement. |timestamp_rep| is substituted for filenames and then passed to |strftime()|. 7. Removed the language setting. |strftime()| should provide this in your favourite language (provided your locale is set correctly) 8. By default the timestamp regexps will NOT match everything after a "Last changed" or "Last modified". It will match exactly a time after each of those expressions! Hence a line like > Last changed: Tue 17 Feb 2004 04:18:40 PM CST < will get replaced with > Last changed: Wed 18 Feb 2004 05:14:16 PM CST < Note that the final is left unchanged! 9. To create a new timestamp in a file, put a line of the form Last changed: TIMESTAMP (other optional stuff) in your file. The TIMESTAMP will get replaced with a timestamp. This only works with the default regexp. If you change that you're on your own 10. To check the entire file, set timestamp_modelines to '%' (instead of the unintuitive '$' as before) ------------------------------------------------------------------------------ > Maintainer: Gautam Iyer Last Modified: Mon 29 Mar 2004 11:09:08 AM CST vim: set ft=help tw=78: