gf-diff : Go to a hunk from diff output
script karma |
Rating 0/0,
Downloaded by 985 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Kana Natsuno |
|
script type |
utility |
|
description |
*gf-diff* is a Vim plugin to extend |gf| and other commands. With this plugin, you can open the file and locate the cursor to a comfortable position from the hunk of a diff output under the cursor. It is useful whenever you review patches and uncommitted changes in Vim.
Suppose that the current buffer contains the following text (here the most left 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 endfunction
If you type |gf| on the 12th line and there is no file whose name is under the cursor, "autoload/gf/diff.vim" will be opened and the cursor will be moved to the 25th line of the file. Because the hunk under the cursor represents the file 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-diff
Document in HTML format: http://kana.github.com/config/vim/gf-diff.html |
|
install details |
... |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 142.132.191.50
|