On 2015-04-23, kamaraju kusumanchi wrote:
> Let's say I have a file that is currently under subversion. Normally,
> I edit the file, save it, go to the konsole, use svn diff to check the
> differences. Instead is it possible to do all this in the vim window
> as follows?
> 
> 1) Edit the file in vim.
> 2) Enter a command or a shortcut key in vim so that the current vim
> window automatically goes into vimdiff mode with left pane showing the
> original version in subversion, right pane showing the current buffer.
> 3) After checking the differences, modify/save the file
> 4) Enter a command or a shortcut key in vimdiff mode to go back to
> just the vim window in step 1.
> 
> Is this vim -> vimdiff -> vim cycle achievable in vim?
Yes.  I do this daily with Perforce, occasionally with Mercurial,
and used to with ClearCase and RCS.  I think you can find plugins
for this, but the code is pretty simple.  Here is my command for
diffing the current buffer against a Mercurial version.  By default,
it uses the latest Mercurial version.
    command! -nargs=? HgDiff vnew | set bt=nofile
                \ | silent exe 'r ++edit !hg cat <args> #'
                \ | silent 0d_ | windo diffthis
For Subversion, which I don't use, you just have to replace the
    hg cat <args> #
part above with the equivalent Subversion command that prints or
cats a version to stdout.  According to "svn help cat", I think that
would be
    svn cat <args> #
Here is the command I most commonly use to go back to normal
editing.  It cancels the diff and closes all but the right window.
    command! -bar -bang Nodiff wincmd l
                \ <bar> only<bang>
                \ <bar> diffoff
HTH,
Gary
-- 
-- 
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
--- 
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment