Ⅰ. 插件描述
Plugin to automatically timestamp filesⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/timestamp-vim'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/timestamp-vim'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/timestamp-vim'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/timestamp.vim
Ⅳ. 文档说明
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: Thu 26 Feb 2004 03:15:54 PM CST
Last Modified: Thu 26 Feb 2004 03:15:55 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 = 'vC%(<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