Show pageOld revisionsBacklinksBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== diff ====== To perform a 'diff' is to view the differences between two files. Vim will automatically show you the different areas by highlighting the lines. You can easily copy those portions between the files if desired. ===== diff from command line ===== diff's are so common that vim comes with a command just for them. To start vim in diff mode with two files, use the vimdiff command: <code> vimdiff <file1> <file2> </code> ===== diff after vim is started ===== If vim is already running, open the first file. Type the following (command mode): <code> :diffsplit file2 </code> ===== diff preferences ===== You can adjust your .vimrc file to customize your diff usage. A common viewing preference is to make diff's show up vertically, instead of horizontally. <code> " make vertical the default diff split (filler was already there) set diffopt=filler,vertical </code> Winmerge is a popular Windows-only application, dedicated to managing diffs. You can simulate the behavior of the Winmerge keys with the following: <code> " disable cmd opt mappings for MacVim (interferes with winmerge mappings) let macvim_skip_cmd_opt_movement = 1 " use diff navigation like winmerge, using alt with up, down, left, right nnoremap <M-Down> ]c nnoremap <M-Up> [c function! CopyToLeft() if !&diff return endif let currwin = winnr() if( currwin == 1 ) :diffget else :diffput endif endfunction function! CopyToRight() if !&diff return endif let currwin = winnr() if( currwin == 1 ) :diffput else :diffget endif endfunction nnoremap <M-Right> :call CopyToRight()<CR> nnoremap <M-Left> :call CopyToLeft()<CR> </code> ===== diffs on directories (multiple files) ===== Vim by default only handles diffs between files. If you need to analyze entire directories, try using the [[docs:diff:dirdiff|DirDiff]] plugin for vim. docs/vim/diff.txt Last modified: 2008/08/03 00:25by 127.0.0.1