savevers.vim : Automatically save and diff multiple, sequentially numbered revisions (like VMS)
script karma |
Rating 217/81,
Downloaded by 7035 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Ed Ralston |
|
script type |
utility |
|
description |
Automatically saves and compares multiple, sequentially numbered
old revisions of files (like in VMS)
If the 'patchmode' option is non-empty, then whenever a file
is saved, a version of the previously saved version is kept,
but renamed to {file}.{number}.{patchext}, where:
{file} is the filename of the file being saved
{number} is a number between 0001 and 9999
{patchext} is the value of the 'patchmode' option.
Optionally, the saved versions can be placed in a subdirectory.
Note that this plugin is DISABLED if 'patchmode' is empty.
Also, this plugin won't work if 'backupdir' is empty or if
'backup' is unset, so to get started, put the following in
your ".vimrc"
set backup
set patchmode=.clean
So, for example, if 'patchmode' is '.clean' and we save a
file named "test.txt" we'll have the following files:
-rw-r----- 1 eralston admin 106 Sep 20 11:14 test.txt
-rw-r----- 1 eralston admin 102 Sep 20 11:12 test.txt.0001.clean
If we make subsequent changes to "test.txt" and save it a
few more times, we'll end up with something like:
-rw-r----- 1 eralston admin 226 Sep 20 11:43 test.txt
-rw-r----- 1 eralston admin 102 Sep 20 11:12 test.txt.0001.clean
-rw-r----- 1 eralston admin 106 Sep 20 11:14 test.txt.0002.clean
-rw-r----- 1 eralston admin 132 Sep 20 11:22 test.txt.0003.clean
-rw-r----- 1 eralston admin 148 Sep 20 11:34 test.txt.0004.clean
COMMANDS:
:Purge [-a] [-v] [N]
Removes all but the patchmode files numbered N and below.
The [N] is optional, and defaults to 1.
Normally, this operates only on the patchmode files associated
with the current buffer, but if the [-a] flag is given, then
it operates on all patchmode files in the directory of the
current file.
If the optional [-v] (verbose) flag is given, then the filename
of each deleted patchmode file is printed.
Use ":Purge 0" to delete all of the patchmode files for the
current file.
Use ":Purge -a 0" to delete all of the patchmode files in
the directory of the current file.
:VersDiff [arg]
Does a "diffsplit" on the current file with the version
indicated by [arg]. So, for example, if the current
file is "test.txt" then the ":VersDiff 5" command will
do a "diffsplit" with "test.txt.0005.clean", assuming
&patchmode is ".clean"
If [arg] is zero (the default), then the diff is done with
the current saved version of the file.
If [arg] is negative, then the diff is done with the
[arg]th oldest file; e.g., if [arg] is "-5" and there are
versions 0001-0023 saved on disk, then the version that
is diffed will be (23-5+1)=19, i.e, "test.txt.0019" will
be diffed.
If [arg] is "-cvs", then the diff is done with the most recently
checked-in version of the file.
If [arg] is "-", then the current VersDiff window is decremented.
If [arg] is "+", then the current VersDiff window is incremented.
(Note that if VersDiff is currently doing a cvs diff, then
the cvs revision is incremented/decremented)
If [arg] is "-c", then any current VersDiff window is closed.
HINTS:
If you use GNU 'ls', then try adding "-I'*.clean'" (without the
double quotes) to your 'ls' alias (assuming &patchmode==.clean)
It's also helpful to have the patchmode value in the backupskip,
suffixes, and wildignore vim options:
:exe "set backupskip+=*" . &patchmode
:exe "set suffixes+=" . &patchmode
:exe "set wildignore+=*" . &patchmode
Also, here are some nice mappings that allow quick comparison
of the current file with previous versions. Pressing <F5>
successively shows the diff with older versions.
" <F5> decrease version viewed in VersDiff window
" <F6> increase version viewed in VersDiff window
" <F7> do VersDiff with cvs version of current file
" <F8> cancel VersDiff window
nmap <silent> <F5> :VersDiff -<cr>
nmap <silent> <F6> :VersDiff +<cr>
nmap <silent> <F7> :VersDiff -cvs<cr>
nmap <silent> <F8> :VersDiff -c<cr> |
|
install details |
Save the plugin as $VIMRUNTIME/plugin/savevers.vim
and you're good to go. The default settings should
work fine for most people, but to enable it, the following
settings (put in .vimrc) should get you started:
set backup
set patchmode=.clean
This plugin can be configured by setting the following
variables in ".vimrc"
savevers_types - This is a comma-separated list of filename
patterns. Sets the types of files that
will have numbered versions.
Defaults to "*" (all files).
savevers_max - Sets the maximum patchmode version.
Defaults to "9999".
savevers_purge - Sets default value of [N] for the :Purge command
Defaults to "1".
savevers_dirs - This is a comma-separated list of directories
that will be tried to store the patchmode files.
The first writable directory in this list is used.
This works much like the vim 'backupdir' option.
To set this to the same as 'backupdir', do
:let savevers_dirs = &backupdir
Defaults to '.', which puts all patchmode files
in the same directory as the original file.
versdiff_no_resize - Disables window resizing during ":VersDiff"
versdiff_max_cols - Limits window resizing during ":VersDiff"
So, for example, if the user has in ~/.vimrc:
let savevers_types = "*.c,*.h,*.vim"
let savevers_max = 99
let savevers_purge = 0
then only "*.c", "*.h", and "*.vim" files will be numbered,
and there will be a maximum of 99 versions saved.
Also, the ":Purge" command will purge all numbered versions
(instead of the default, which is to delete all but the oldest).
|
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|