sponsor Vim development Vim logo Vim Book Ad

DiffGoFile : Jump to file from diff output

 script karma  Rating 11/7, Downloaded by 848  Comments, bugs, improvements  Vim wiki

created by
Vladimir Marek
script type
Script home: https://github.com/vlmarek/DiffGoFile

If you are editing diff file and you want to jump quickly to corresponding source files, function DiffGoFile does that. Place cursor on the spot in diff file which interests you, call DiffGoFile and you will be presented with the source file exactly at the place you were looking at. Currently only unified diff is supported, but the script has framework for adding more types.

Place cursor on the line you are interested in and
:call DiffGoFile('X')
Where X is one of: n - open in New window
                   v - open in Vertical split
                   h - open in Horizontal split
                   t - open in new Tab

You may wish to setup a hotkey, I'm using CTRL-] (:tag) for example

autocmd FileType diff nnoremap <buffer> <C-]> :call DiffGoFile('n')<CR>
install details
If you are upgrading from version 1
  - remove ~/.vim/plugin/diffgofile.vim

Copy the file to the proper location
  - mkdir -p ~/.vim/ftplugin
  - cp diff_gofile.vim ~/.vim/ftplugin

Make sure that you are using ftplugins
  - add "filetype plugin on" to your ~/.vimrc

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
diffgofile.zip 4 2013-08-16 6.0 Vladimir Marek More clever repository root detection
diff_gofile.vim 2 2007-05-10 7.0 Vladimir Marek * Ability to open the source file in new buffer/vertical split/horizontal split/new tab
* Script was reworked to became ftplugin
diffgofile.vim 1 2007-05-07 7.0 Vladimir Marek Initial upload
ip used for rating:

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.