Wikia

Vim Tips Wiki

Changes: Update the diff view automatically

Edit

Back to page

(merge in comment, still need to merge in vim_use discussion)
 
Line 15: Line 15:
 
<pre>
 
<pre>
 
" If doing a diff. Upon writing changes to file, automatically update the
 
" If doing a diff. Upon writing changes to file, automatically update the
" differences
+
" differences
au BufWritePost * if &diff == 1
+
autocmd BufWritePost * if &diff == 1 | diffupdate | endif
au BufWritePost * :diffupdate
 
au BufWritePost * endif
 
 
</pre>
 
</pre>
   
 
==Comments==
 
==Comments==
 
A [http://groups.google.com/group/vim_use/browse_thread/thread/64d65c0400010e01 more aggressive auto-diffupdate] is discussed on vim_use and should probably be merged into this tip.
 
A [http://groups.google.com/group/vim_use/browse_thread/thread/64d65c0400010e01 more aggressive auto-diffupdate] is discussed on vim_use and should probably be merged into this tip.
 
* It works for me quit well. I use a slightly modified version:
 
 
<pre>
 
autocmd BufWritePost * if &diff == 1 | :diffupdate | endif
 
</pre>
 

Latest revision as of 13:58, May 12, 2010

Tip 149 Printable Monobook Previous Next

created October 29, 2001 · complexity intermediate · author Douglas Potts · version 6.0


When trying to reconcile differences between files, and using the new 'diff' functionality in Vim 6.0 you may want to automatically update the differences as you are working along. A convienent time is when you write out either of the files you are diff'ing. This autocmd will take care of doing that for you.

" If doing a diff. Upon writing changes to file, automatically update the
" differences
autocmd BufWritePost * if &diff == 1 | diffupdate | endif

CommentsEdit

A more aggressive auto-diffupdate is discussed on vim_use and should probably be merged into this tip.

Around Wikia's network

Random Wiki