Ⅰ. 插件描述
Automatically write a backup on the first write.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin '/writebackupautomator'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle '/writebackupautomator'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug '/writebackupautomator'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/vim-scripts/writebackupAutomator
Ⅳ. 文档说明
DESCRIPTION
Unless you use a revision control system, you have to write backups yourself.
The writebackup.vim plugin makes that a simple :WriteBackup command from
within Vim, but you still have to remember to trigger the backup. The
writebackupVersionControl.vim extension can make up for a missed backup when
you have already made changes to the buffer, but have not persisted them yet,
via :WriteBackupOfSavedOriginal. Still, wouldn't it be nice if Vim detected
that you have made backups of a file in the past, and automatically creates a
new backup - without any action on your side?
This plugin builds on the writebackup.vim and
writebackupVersionControl.vim plugins, and automatically writes a backup on
a day's first write of a file that was backed up in the past, but not yet
- This gives you one no-hassle, worry-free backup every day. For many
writebackup.vim use cases (like editing config files distributed all over
/etc/), this initial "good state from the past" backup is the most important
- (And of course you can still manually trigger additional checkpoint
- via :WriteBackup as in the past.)
USAGE
Once any backup exists (you can check via :WriteBackupListVersions), a new
backup will be written on each day when you first persist the buffer via
:write, provided that the file has not been modified yet today. (Otherwise,
you would not be able to undo the automatic backup via
:WriteBackupDeleteLastBackup; the automatic backup would keep reappearing
after each :write.) Watch out for file synchronization tools and version
control systems that may silently update the file modification date to today
and therefore prevent automatic backups!
For this and other reasons, it is still a good practice to trigger backups via
:WriteBackup yourself, and just use the writebackupAutomator plugin as a
safety net, for those instances where you forget to backup.