Ⅰ. 插件描述
Vim plugin: Go to the changed block under the cursor from diff outputⅡ. 基本信息
|
Ⅲ. 安装方法
使用Vundle管理器安装
在你的.vimrc下添加:Plugin 'kana/gf-diff'
… 然后在Vim中运行以下命令:
:source %
:PluginInstall
对于Vundle版本 < 0.10.2,请用上面的Bundle替换Plugin。
使用NeoBundle管理器安装
在你的.vimrc下添加:NeoBundle 'kana/gf-diff'
… 然后在Vim中运行以下命令:
:source %
:NeoBundleInstall
使用VimPlug管理器安装
在你的.vimrc下添加:Plug 'kana/gf-diff'
… 然后在Vim中运行以下命令:
:source %
:PlugInstall
使用Pathogen管理器安装
在终端中运行以下命令:cd ~/.vim/bundle
git clone https://github.com/kana/vim-gf-diff
Ⅳ. 文档说明
gf-diff is a Vim plugin to extend |gf| and other commands. With thisplugin, you can open the file and locate the cursor to a comfortable positionfrom the hunk of a diff output under the cursor. It is useful whenever youreview patches and uncommitted changes in Vim.Suppose that the current buffer contains the following text (here the mostleft numbers are line numbers): 1 diff --git a/autoload/gf/diff.vim b/autoload/gf/diff.vim 2 index 469fdb3..b135316 100644 3 --- a/autoload/gf/diff.vim 4 +++ b/autoload/gf/diff.vim 5 @@ -21,7 +22,7 @@ 6 " SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 7 " 8 " Interface 9 -function! gf#diff#go_to_hunk(type) 10 +function! gf#diff#go(type) 11 let d = gf#diff#investigate_the_hunk_under_the_cursor() 12 if d is 0 13 echomsg 'There is no diff hunk to jump.' 14 @@ -113,7 +114,7 @@ function! gf#diff#investigate_the_hunk_under_the_c 15 return 0 16 endif 17 let [d.from_path, d.to_path] = xs 18 + call setpos('.', original_position) 19 - call setpos(original_position) 20 21 return d 22 endfunctionIf you type |gf| on the 12th line and there is no file whose name is under thecursor, "autoload/gf/diff.vim" will be opened and the cursor will be moved tothe 25th line of the file. Because the hunk under the cursor represents thefile and the position.Requirements:- Vim 7.3 or later- |gf-user| 0.0.0 or later (vimscript#3891, http://github.com/kana/vim-gf-user)Latest version:http://github.com/kana/vim-gf-diffDocument in HTML format:http://kana.github.com/config/vim/gf-diff.html