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.
Regards,
Gary
--
--
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/groups/opt_out.