sponsor Vim development Vim logo Vim Book Ad

gf-diff : Go to a hunk from diff output

 script karma  Rating 0/0, Downloaded by 158    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
...
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
vim-gf-diff-0.1.1.zip 0.1.1 2012-01-18 7.0 Kana Natsuno Initial upload
ip used for rating: 54.242.231.109

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo