gf-diff : Go to a hunk from diff output
| script karma
Downloaded by 269
Comments, bugs, improvements
|*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.
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
17 let [d.from_path, d.to_path] = xs
18 + call setpos('.', original_position)
19 - call setpos(original_position)
21 return d
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.
- Vim 7.3 or later
- |gf-user| 0.0.0 or later
Document in HTML format:
Rating scripts is only available on the
script versions (upload new version)
Click on the package to download.
ip used for rating: 184.108.40.206