Loading ...
Sorry, an error occurred while loading the content.

Re: Feature request: vimdiff and foldmethod

Expand Messages
  • Gary Johnson
    ... From the comments above that command: Update: 2006-12-05: Added foldlevel=99 so folds closed by diff would not be left closed. I think the reason
    Message 1 of 6 , May 26, 2013
    • 0 Attachment
      On 2013-05-26, Christian Brabandt wrote:
      > Hi Gary!
      > On Sa, 25 Mai 2013, Gary Johnson wrote:
      > > On 2013-05-25, Marcin Szamotulski wrote:
      > > > Dear Vim Dev,
      > > >
      > > > I have a proposition for a small but nice feature. Whenever I do
      > > > diff & then diffo (or diffo!) some settings are lost, for example the
      > > > foldmethod is always reset to manual. It would be nice if vim could
      > > > restore fdm setting to what it was set before doing the diff. I don't
      > > > have an idea how to do that in VimL since there is no autocommand and
      > > > there is no way of user over writting vim commands.
      > >
      > > I agree that this would be a nice feature. Here is some of what
      > > I've done to work around this.
      > >
      > > This autocommand remembers the foldmethod of each buffer.
      > >
      > > " Remember the current 'foldmethod' so that it can be restored
      > > " after a diff by the Nodiff or Undiff command.
      > > "
      > > au BufWinEnter * if &fdm != "diff" | let b:fdm = &fdm | endif
      > >
      > > Rather than use :diffoff, I use my own commands such as the
      > > following Undiff to exit diff mode and clean up related settings
      > > such as 'foldmethod'.
      > >
      > > command! -bar -bang Undiff let wn=winnr()
      > > \ <bar> diffoff!
      > > \ <bar> windo set foldlevel=99
      > > \ <bar> set virtualedit=
      > > \ <bar> windo exe 'if exists("b:fdm") <bar> let &fdm = b:fdm <bar> endif'
      > > \ <bar> windo exe 'if exists("b:syn") <bar> let &l:syn = b:syn <bar> endif'
      > > \ <bar> exe wn . 'wincmd w'
      > >
      > > I have other hooks that set 'virtualedit' to "all" when diff mode is
      > > entered, and I hardly ever use it otherwise, so I don't bother to
      > > save and restore its original value.
      > Why are you setting fdl=99? (this would also set this value in windows,
      > that were not in diff mode)

      From the comments above that command:

      " Update: 2006-12-05: Added "foldlevel=99" so folds closed by
      " diff would not be left closed.

      I think the reason for setting the 'foldlevel' for all windows was
      that I hardly ever leave folds closed for very long unless they are
      closed by diff and I never diff two windows in a situation where any
      of my windows contain closed folds. So, the 'foldlevel' of all my
      windows before executing the diff was already some high value.

      You're right that it is not the correct solution for the general
      case, but it was easy to implement and it works in every situation I
      care about.


      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 vim_dev+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    Your message has been successfully submitted and would be delivered to recipients shortly.