Olaf Dabrunz wrote:
> On 21-Jun-15, Manuel Ortega wrote:
> > Doing ":h diffoff" gives:
> >
> > The ":diffoff" command resets the relevant options to the values they
> > had when using |:diffsplit|, |:diffpatch| , |:diffthis|. or starting Vim
> > in diff mode. Otherwise they are set to their default value:
> >
> > 'diff' off
> > 'scrollbind' off
> > 'cursorbind' off
> > 'scrollopt' without "hor"
> > 'wrap' on
> > 'foldmethod' "manual"
> > 'foldcolumn' 0
> >
> > What this doesn't tell you is that :diffoff will perform this resetting
> > under more circumstances than mentioned, namely if diff mode was already
> > off; but in this circumstance, the resetting is both unexpected and
> > undesirable.
>
> This is intentional. There have been discussions and patches touching
> this:
>
> [PATCH] :diffoff should not change settings for non-diff windows
> Lech Lorens
> https://groups.google.com/forum/#!topic/vim_dev/UEqB5ppy49g
>
> [patch] diffoff! does not check &diff in current window
> Charles Cooper
> https://groups.google.com/forum/#!topic/vim_dev/IOvSxDIJIqY
>
> The documentation for 'diffoff' was updated in 7.4.490:
>
> :diffo[ff] Switch off diff mode for the current window. Resets
> related options also when 'diff' was not set.
>
> ':diffoff' works even when the current window does not have 'diff' set,
> because people tend to ':set nodiff', and only then remember to
> ':diffoff' to get rid of the other settings made by ':diffthis'.
>
> > Specifically, if you forget that diff mode is already off and you do
> > :diffoff a second time, you will lose &scrollbind, &foldmethod, &wrap,
> > etc if you had them set to something other than those defaults. This is
> > really annoying. I kept wondering what happened to my folds!
> > Sometimes I had &scrollbind on outside of diff mode, and I lost it after
> > inadvertently doing a second :diffoff.
>
> So the problem seems to be that ':diffoff' forgets about the saved
> values when it is used the first time, so on the second ':diffoff' it
> restores the defaults.
>
> The patch below changes this so that the saved settings are never
> forgotten. And with the patch they get updated whenever ':diffthis' or
> friends are used on a window that is not yet in 'diff' mode.
>
> So a second ':diffthis' in a diff window does not overwrite the settings
> saved when entering diff mode. And a second ':diffoff' restores the
> settings that were saved the last time when this window entered diff
> mode.
>
> A second ':diffoff' can of course still lose settings that you made
> after the first ':diffoff'. But I do not see a simple solution for
> that. Maybe you can live with that.
>
> No documentation in the patch, because in my understanding the current
> docs seem to imply this behavior:
>
> The ":diffoff" command resets the relevant options to the values
> they had when using |:diffsplit|, |:diffpatch| , |:diffthis|. or
> starting Vim in diff mode. Otherwise they are set to their default
> value:
>
>
> With the patch, ':diffoff' will only restore the defaults if the window
> has never been in a diff.
Thanks, I guess this will work for everyone.
> Question to the list: should ':diffoff' *ever* restore default settings?
>
> Maybe it is better to only restore settings that have been saved before,
> when entering diff mode at some point, if that has happened at all.
>
> Because if the window was never switched to diff mode, why should
> ':diffoff' restore settings that have never been changed by diff mode,
> and then to some arbitrary defaults? Better leave these settings
> untouched in that case?
Not sure if someone would type :diffoff without entering diff mode,
other then doing this intentionally to get some options into a sane
state.
--
hundred-and-one symptoms of being an internet addict:
140. You'd rather catch a score on the web than watch the game as
it is being played on tv.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" 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_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.