writebackupToAdjacentDir : Backup to an adjacent backup directory.
| script karma |
Rating 10/4,
Downloaded by 204
|
Comments, bugs, improvements
|
Vim wiki
|
| created by |
| Ingo Karkat |
| |
| script type |
| utility |
| |
| description |
Redirect backups made by the writebackup plugin (vimscript #1828) that would
normally go into the original file's directory into an adjacent directory with a
"{dir}.backup" name, if it exists. This allows to use the plugin in places where
backup files would cause problems.
DESCRIPTION
Many customization directories (e.g. /etc/profile.d/) consider all contained
files, regardless of file extension or execute permissions. Creating a
{file}.YYYYMMDD[a-z] backup in there causes trouble and strange effects,
because the backups are used in addition to the main configuration file - not
what was intended! However, putting the backups in the same directory
generally is a good idea - just not for these special directories.
This plugin offers a solution by integrating into the writebackup.vim plugin
so that it checks for a directory with a '.backup' extension (e.g.
/etc/profile.d.backup/), and places the backups in there, in case it exists.
In all other cases, the backup is made in the default directory, as before.
USAGE
Adjacent backup directories are never created by this plugin; you have to
create such a directory yourself to indicate that backups should be placed in
there.
:WriteBackupMakeAdjacentDir [{prot}]
Create a backup directory adjacent to the current file's
directory. If {prot} is given it is used to set the protection
bits; default is 0755.
After the adjacent backup directory has been created, just use :WriteBackup
as before. |
| |
| install details |
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vba.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 writebackupToAdjacentDir.vba.gz
:so %
To uninstall, use the :RmVimball command.
DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the writebackup plugin (vimscript #1828), version 1.30 or
higher.
- The writebackupVersionControl plugin (vimscript #1829), which
complements writebackup, fully supports this extension, but is not
required.
CONFIGURATION
For a permanent configuration, put the following commands into your vimrc (see
:help vimrc):
To change the name of the adjacent backup directory, specify a different
template via
let g:WriteBackupAdjacentDir_BackupDirTemplate = '%s.backup'
This must contain the "%s" placeholder, which is replaced with the original
file's directory, e.g. "backup of %s".
This plugin injects itself into writebackup.vim via the
g:WriteBackup_BackupDir configuration. Its previous value is saved in
g:WriteBackupAdjacentDir_BackupDir and used as a fallback, when no adjacent
directory exists. If you need to change the fallback after sourcing the
plugins, use the latter variable. However, to override this for a particular
buffer, you still have to use the b:WriteBackup_BackupDir variable, as this
plugin does not provide yet another override. |
| |
script versions (upload new version)
Click on the package to download.
ip used for rating: 54.224.75.101
|