Diffmode - 'Diffupdate on Save'

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Diffmode - 'Diffupdate on Save'

Dominic Evans
Hi,

Is there an easy addition to my .vimrc to make Vim do a 'diffupdate'
automatically every time I save one of the buffers being diffed?

Should this not be the default thing to do anyway?

Regards,
Dom
Reply | Threaded
Open this post in threaded view
|

Re: Diffmode - 'Diffupdate on Save'

Bram Moolenaar

Dominic Evans wrote:

> Is there an easy addition to my .vimrc to make Vim do a 'diffupdate'
> automatically every time I save one of the buffers being diffed?

I didn't try it, but this should work:

        :au BufWritePost * diffupdate

> Should this not be the default thing to do anyway?

Why?  Mostly the diff is updated when making changes.  When it gets out
of sync you need to invoke ":diffupdate", but that is not directly
related to writing the file.  One might as well want this for ":!ls" or
":help".  At least I wouldn't want a user to write the file to get the
diffs updated.

--
You are not really successful until someone claims he sat
beside you in school.

 /// Bram Moolenaar -- [hidden email] -- http://www.Moolenaar.net   \\\
///        Sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\              Project leader for A-A-P -- http://www.A-A-P.org        ///
 \\\     Buy LOTR 3 and help AIDS victims -- http://ICCF.nl/lotr.html   ///
Reply | Threaded
Open this post in threaded view
|

RE: Diffmode - 'Diffupdate on Save'

Halim, Salman
In reply to this post by Dominic Evans
Sometimes, when I make a major change, an explicit diffupdate is called
for (when, as you mention, the diff gets out of sync).  Usually, I like
to save major changes (call me paranoid), so I do use this:

au BufWritePre * if (&diff) | diffupdate | endif

Basically, if you have multiple windows open and not all are
participating in a diff, why update the diff if the window you're saving
isn't actually the one being diffed, I figure :)

Regards,

Salman.

> -----Original Message-----
> From: [hidden email] [mailto:[hidden email]]
> Sent: Thursday, September 01, 2005 8:35 AM
> To: Dominic Evans
> Cc: [hidden email]
> Subject: Re: Diffmode - 'Diffupdate on Save'
>
>
> Dominic Evans wrote:
>
> > Is there an easy addition to my .vimrc to make Vim do a 'diffupdate'
> > automatically every time I save one of the buffers being diffed?
>
> I didn't try it, but this should work:
>
> :au BufWritePost * diffupdate
>
> > Should this not be the default thing to do anyway?
>
> Why?  Mostly the diff is updated when making changes.  When
> it gets out of sync you need to invoke ":diffupdate", but
> that is not directly related to writing the file.  One might
> as well want this for ":!ls" or ":help".  At least I wouldn't
> want a user to write the file to get the diffs updated.
>
> --
> You are not really successful until someone claims he sat
> beside you in school.
>
>  /// Bram Moolenaar -- [hidden email] --
> http://www.Moolenaar.net   \\\
> ///        Sponsor Vim, vote for features --
> http://www.Vim.org/sponsor/ \\\
> \\\              Project leader for A-A-P --
> http://www.A-A-P.org        ///
>  \\\     Buy LOTR 3 and help AIDS victims --
> http://ICCF.nl/lotr.html   ///
>