Ⅰ. 插件描述
Port of Sublime Text local-history plugin for VimⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'mg979/vim-localhistory'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'mg979/vim-localhistory'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'mg979/vim-localhistory'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/mg979/vim-localhistory
Ⅳ. 文档说明
### Vim Local History
Introduction
This plugin creates automatic and/or manual backups for your files, in
predefined paths. Backups can be browsed with fzf-vim.
Features:
- automatic backup directories generation, mirroring actual file path
- save backups with date or name (snapshots)
- load/delete backups with fzf
- diff with dated backups/snapshots
- optional autobackup on first load (configurable max size)
- optional autobackup on save, if no recent backups are found (configurable)
Requirements
fzf-vim is required.
Tested in Linux only.
Installation
Use vim-plug or any other Vim plugin manager.
With vim-plug:
Plug 'mg979/vim-localhistory'
Usage
You can set the base directory:
let g:lh_basedir = '~/.vim/local_history'
When saving a backup, the file will mirror the original path inside the base dir:
/some/path/file -> ~/.vim/local_history/some/path/file
Disable keymappings with:
let g:local_history_disable_mappings = 1
Change the position in which files are opened (eg. vs, sp, edit, botright vs, etc):
let g:lh_open_mode = 'bo vs'
Set to 0 if you prefer horizontal split for diff windows:
let g:lh_vert_diff = 0
Autobackup
To enable autobackup, you must first set these variables. It will only work
after Vim has been restarted. Max size affects both types of autobackup.
Activate autobackup on first access to a file, and max size (default 10240 bytes):
let g:lh_autobackup_first = 1
let g:lh_autobackup_size = 51200
Activate autobackup after save, if no recent backup is found (frequency in minutes):
let g:lh_autobackup_frequency = 60
Commands
| Command | Mapping | Default |
|---|---|---|
| :LHwrite | <Plug>LHWriteDated | ght |
| :LHwrite <name> | <Plug>LHWriteSnapshot | ghs |
| :LHdiff | <Plug>LHDiff | ghd |
| :LHdated | <Plug>LHLoadDated | ghT |
| :LHsnapshot | <Plug>LHLoadSnapshot | ghS |
| :LHdelete | <Plug>LHDelete | ghD |
| :LHall | <Plug>LHLoadAll | gha |
LHwrite : write a backup with date
LHwrite <name> : write a named backup (snapshot)
LHdated : load a backup with a date
LHsnapshot : load a snapshot
LHdiff : select a backup and open a split diff window
LHdelete : delete backups for current dir (all types)
LHall : load any backup
LHdated, LHsnapshot, LHdiff, LHall and LHdelete use fzf-vim, and you can
select multiple files.
Credits
Braam Moolenaar for Vim
License
MIT