On Fri 11-Aug-06 6:55pm -0600, Mark Woodward wrote:
>> This command was posted by Piet Delport a few years ago. I use it
>> all the time.
>>
>> command DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis |
>> wincmd p | diffthis
>>
>> Gary
>
> I can see why you use this all the time. BRILLIANT!
> It should certainly be a tip on vim.org if it isn't already!!
>
> I just threw this in my .vimrc and I'll too be using it all the time.
> (I used :command! though (note the !))
I've been using a form of this, enhancing it over time.
Here is my current version:
" This command was posted by Piet Delport a few years ago.
" com DiffOrig vert new | se bt=nofile | r # | 0d_ | difft | winc p | difft
"
" DT is a form of "diffthis" to compare the file being
" edited with the file on disk. It is an enhanced version
" of Piet's DiffOrig. DO turns off diff mode.
"
" What has been added to Piet's original is changing the font
" to something more appropriate for diff-ing, and saving all
" settings changed my the process. Note that, when invoked,
" all other windows are first closed and the new widow comes
" up on the right (what's on disk) as a [Scratch] file.
"
" Also DO is a form of "diffoff" which restores things
" changed by DT and removes temp variables. Note that this
" does a bwipe of the scratch buffer and, because it uses
"diffoff", it only works for Version 7+. It doesn't matter
" whether you are in the editing or scratch buffer when you
" invoke DO.
"
" Change the guifont, if applicable, to something that fits
" your screen. If you use colorschemes, you may what a
" different one for diff-ing.
"
" Bill McCarthy 11-Aug-2006
com! DT sil on! | let oft = &ft | vert bel new
\| exec 'setl bt=nofile ft=' . oft | let obnr = bufnr("%")
\| let oscb = &scb | let osbo = &sbo | let owrap = &wrap
\| let ofdm = &fdm | let ofdc = &fdc
\| let oco = &co | let olines = &lines
\| if has("gui") | let ogfn = &gfn | se gfn=andale_mono:h8 | en
\| se co=999 lines=99
\| sil r # | sil 0d_ | difft | winc p | difft | winc =
com! DO diffo | sil exec 'bw! ' . obnr
\| let &scb = oscb | let &sbo = osbo | let &wrap = owrap
\| let &fdm = ofdm | let &fdc = ofdc
\| if has("gui") | let &gfn = ogfn | unlet ogfn | en
\| let &co = oco | let &lines = olines
\| unl oscb osbo owrap ofdm ofdc oco olines oft obnr
--
Best regards,
Bill