8000 GitHub - pchaos/timestamp.vim: Plugin to automatically timestamp files
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

pchaos/timestamp.vim

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This is a fork of http://www.vim.org/scripts/script.php?script_id=923. 
Last Modified:      2023-07-03 20:02:30
Rewrited by python

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. Your search (and all other) history is unaltered, however you might find an extra mark in your jumplist.

All the default variables and actions can be changed by buffer / global vim variables. See |timestamp_examples for two simple examples.

By default, this plugin will timestamp ANY file that matches the regexp |timestamp_regexp| in the first and last 'modelines' (default 5) lines of your file. The default value of |timestamp_regexp| will EITHER match 'TIMESTAMP' or a time (in the format of strftime("%c")) FOLLOWED by a 'Last changed:' or 'Last modified:'. For instance, if you create a new file and want to stamp it with a creation date and a last modified date, make the first few lines: >

    Created:            TIMESTAMP
    Last Modified:      TIMESTAMP

When you first write the file, these lines will change to: >

    Created:            2023-07-03 19:59:07
    Last Modified:      2023-07-03 19:59:07

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%(<Last %([cC]hanged?|[Mm]odified):\s+)@<=.*$'

in your .vimrc. This however has the disadvantage of eating all the text after the colon in any timestamp line.

Read the complete htmlised documentation at http://math.stanford.edu/~gautam/opensource/xterm16/timestamp-doc.html

About

Plugin to automatically timestamp files

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Python 62.1%
  • Vim Script 37.9%
0