DESCRIPTION
This plugin automatically adapts information like "last modified" timestamps
and copyright notices, or applies any other substitution before each file
save. Where and what is replaced can be configured globally and for each
individual buffer.

The plugin ships with configuration defaults which handle the most common
copyright notices, e.g.:
Copyright: (C) 2011-2014 Ingo Karkat
and modification timestamps such as
Last Change: Wed 15 Jan 2014 21:38:00 WEST
Modified: 2014 Jan 15

RELATED WORKS
- autodate.vim (vimscript #291) is an old plugin that can insert and update a
time stamp (between a prefix and postfix) in a certain format.
- ferallastchange.vim (vimscript #680) is an old plugin that searches for a
prefix and then updates the timestamp in a certain format.
- timstamp.vim (vimscript #371) takes pattern and replacement parts like this
plugin (the replacement part also supports some custom tokens e.g. for
hostname), and is functionally very close.
- timestamp.vim (vimscript #923) is based on timstamp.vim. It allows only one
pattern and feeds the replacement part to strftime(), making it less
general.
- header.vim (vimscript #1142) insert or updates a header at the top, in a
rather primitive way, and limited to shell, Python, Perl, and Vim scripts.
- lastmod.vim (vimscript #3578) is a short and simple plugin for replacing one
pattern with a timestamp in the first N lines.
- better-header.vim (vimscript #4676) can insert and update a header for
Python and shell scripts, and requires Python itself.
- update-time (vimscript #4786) searches the first and last lines for a single
prefix and then automatically updates a following timestamp.

USAGE
The adaptation happens before every buffer save (BufWritePre event), e.g.
with the :write command. No action required. You can configure
(g:AutoAdapt_Rules) and disable this, though:

:NoAutoAdapt Turn off automatic adapting for the current buffer.

:AutoAdapt[!] Turn on automatic adapting for the current buffer,
after having it turned off via|:NoAutoAdapt|, or to
enable adapting for a buffer when the automatic
adapting has been configured to exclude the current
buffer via g:AutoAdapt_FilePattern, or (with [!]) to
override a configured Predicate which disables
adaptation for the buffer.

:Adapt[!] Trigger manual adaptation of the current buffer (when
automatic adaption has been turned off via
:NoAutoAdapt). With [!] also overrides a configured
Predicate which disables adaptation for the buffer.

install details

INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
vim AutoAdapt*.vmb.gz
:so %
To uninstall, use the :RmVimball command.

CONFIGURATION
For a permanent configuration, put the following commands into your vimrc:

If you want to apply the adaptation only to certain files, you can specify
autocmd-patterns instead of the default "*". This must be set before the
plugin is sourced:
let g:AutoAdapt_FilePattern = '*.h,*.c,*.cpp'
Alternatively, if you want to opt-in for certain files only instead of opting
out via :NoAutoAdapt, completely disable the automatic adaptation through
let g:AutoAdapt_FilePattern = ''
and use :AutoAdapt, e.g. in combination with a local vimrc plugin.

The number of lines at the start of the buffer when the rules are applied by
default:
let g:AutoAdapt_FirstLines = 25

The number of lines at the end of the buffer when the rules are applied by
default:
let g:AutoAdapt_LastLines = 10
The reasoning for a larger "first lines" value is that there may be more
boilerplate code at the file's header. (Also for this reason, the 'modelines'
value is not used by default.)
You can override both values for particular buffers / filetypes with the
buffer-scoped variable.

name An optional, human-readable description of the rule.
pattern The regular-expression as used in a :substitute
command (with the separator character /, or
substitutionSeparator).
patternexpr A Funcref (that takes the entire current rule object)
or a String that is |eval()|ed to yield the pattern.
Updates the pattern attribute on each run. You can use
this to e.g. get the current date (via strftime(),
to avoid a match of the current date with /@!) into
the pattern. The Funcref can throw "AutoAdaptSkip" to
skip the application of this rule.
replacement The replacement; you can use text or
sub-replace-special.
range The (optional) range to which parts of the buffer the
rule will be applied. It defaults to the empty string
"", which uses the g:AutoAdapt_FirstLines and
g:AutoAdapt_LastLines variables. Alternatives are:
"modelines", which considers the 'modelines' number of
lines at both the start and end of the buffer.
You can also use "%" for the entire buffer, or use
numbered ranges "11,42".
substitutionSeparator The separator in the :substitute. Change from the
default "/" to another non-alphanumeric single-byte
character when the default is cumbersome. E146

To skip the automatic adaptation for certain files, in addition to
g:AutoAdapt_FilePattern and :NoAutoAdapt, you can also configure a Funcref
(if that is more convenient) that is passed the current file's filespec, and
should return a Boolean value whether it should be adapted. For example, if
you have the writebackupVersionControl.vim plugin (vimscript #1829)
installed, you can skip adapting backups via:
let g:AutoAdapt_Predicate = function('writebackupVersionControl#IsOriginalFile')

INTEGRATION
After each write, the plugin sets the variable b:AutoAdapt to the number of
rules that have been applied. If no rule was applied, the variable is removed.
The :NoAutoAdapt sets the variable to 0 to indicate that the plugin is
disabled for that buffer.

If you want to indicate (e.g. in your 'statusline') whether automatic adapting
took place or whether you've manually overridden the automation, you can use
the AutoAdapt#Info#Status() function, which returns:
"adapted" when adaptation took place
"noadapt" when automatic adaptation is enabled, but was turned off via
:NoAutoAdapt for this buffer
"adapt" when automatic adaptation is disabled, but was turned on via
:AutoAdapt for this buffer
"" in all other situations