Ⅰ. 插件描述
View git diff in Vim tabs.Ⅱ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'bootleq/vim-gitdiffall'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'bootleq/vim-gitdiffall'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'bootleq/vim-gitdiffall'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/bootleq/vim-gitdiffall
Ⅳ. 文档说明
gitdiffall
View git diff in Vim tabs.
gitdiffallfunction for zsh (requires ruby for running _gitdiffall.rb_).GitDiff,GitDiffInfo,GitDiffOffcommands for Vim.
Install
Install like general Vim plugins.
Install Zsh Helper Function
With [zplug][] (preferred way)
zplug "bootleq/vim-gitdiffall", use:"bin/*.zsh"or Manual install
- Execute install.zsh (will ask you for copying scripts to path).
- Source path/to/gitdiffall.zsh in your _.zshrc_.
if [ -e ~/some_dir/gitdiffall.zsh ]; then source ~/some_dir/gitdiffall.zsh fi
Zsh Function Usage
In zsh, use gitdiffall to open git diff in Vim tabs, examples:
gitdiffalldiff current unstaged/staged changes, likegit diff.gitdiffall --cacheddiff staged changes with HEAD.gitdiffall dae86esee all changes since commit "dae86e".gitdiffall HEAD..HEAD~2works likegit diff HEAD..HEAD~2.
For convenience, some special notations are available:
gitdiffall @dae86eexpands todae86e^..dae86e,
this is a shortcut for checking changes at specific commit.
Examples: @@~2 (HEAD~2), @stash@{0} (stashed entry), @master (last commit at master branch).
gitdiffall 1is similar to@<rev>, where<rev>is the 1st previous commit from HEAD.
You can increase the digit for older commits.gitdiffall jandgitdiffall kshortcut to next_/_previous commit from last evaluatedgitdiffall <n>.
(this uses environment variable$_GITDIFFALL_LAST_SHORTCUTto remember last eval)
During merge conflicts, gitdiffall will open a 3-way diff in Vim.
Zsh Function Configuration
gitdiffall.rb takes configure file from one of the following:
~/gitdiffall/config.rb~/gitdiffall-config.rb{dir_contains_gitdiffall.rb}/gitdiffall/config.rb{dir_contains_gitdiffall.rb}/gitdiffall-config.rb
Supported config items:
editor_cmd(default: "vim")
Command to execute Vim.max_files(default: 14)
Wait for confirmation before open such many files.min_hash_abbr(default: 5)
When performinggitdiffall <n>,
<n> must have this many digits to indicate a hash,
otherwise it's a number.
ignore_pattern(default:/\.(png|jpg)\Z/i)
Files match this pattern will not be sent to Vim.
Example config.rb:
CONFIG = {
:editor_cmd => "vim -u /some/other/vimrc",
:max_files => 14,
:min_hash_abbr => 5,
:ignore_pattern => /(\.(png|jpg)|-compressed\.js)\Z/i
}Tips
In tmux copy mode, select some commit hash and press > to do gitdiffall in
new tmux window, see [tmux-in.rb][] gist.
bind -t vi-copy > copy-pipe "~/.tmux-in.rb gitdiffall"