Hello everybody,

I have a plugin for (unified) diff files that I think might be of interest to 
other people, too.

If you put the attached file as 
        /usr/share/vim/vimcurrent/plugin/diff.vim
you can press <CR> at the "@@ -x,x +x,x @@" lines in a diff
to jump to that chunk in the file.

That's very nice if you're doing things like
        :!svn diff > /tmp/a.patch
        :e /tmp/a.patch
to review your changes before committing.


I hope that it finds some interest; feedback is welcome, of course.


Regards,

Phil

--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

" Plugin to allow pressing <CR> on the line number information lines
" ( @@ -xx,xx +xx,xx @@ ) in unified diffs, to jump to that position in that
" file.


noremap <silent> <buffer> <cr> :call DiffJump()<CR>

function! DiffJump()
	let line=getline(".")
	if line =~ '^@@ -\d\+,\d\+ +\d\+,\d\+ @@'
		" Maybe allow to go to the "old" line?
		let dest=matchstr(line, '+\d\+')
		let filename_linenumber=search('^+++ ', "bnW")
		" With the given pattern the filename always starts in byte 5.
		let t1=strpart(getline(filename_linenumber), 4)
		" Remove tab and all behind.
		let file=substitute(t1, '\t.*$', '', '')
		exe "edit " . dest . " " . file
	else
		echo "Line doesn't include line numbers"
	endif
endfunction

Raspunde prin e-mail lui