Icdiff: side-by-side command line diffs
jefftk.com
jefftk.com
Git integration with fugitive is also worth mentioning. It makes partial committing and cherry picking very easy.
Either way, icdiff looks very promising.
http://i.imgur.com/VOlbMoy.png
icdiff seems to have the best defaults for me.
Not that this applies here, but it is something to consider.
cdiff() {
diff -u "$@" \
| sed 's/^\(@@ .* @@\)$/'$'\e[36m''\1'$'\e[m''/g' \
| sed 's/^\(-.*\)$/'$'\e[31m''\1'$'\e[m''/g' \
| sed 's/^\(+.*\)$/'$'\e[32m''\1'$'\e[m''/g' \
| less -c -R
}icdiff colors just the part of the line that changed: http://www.jefftk.com/icdiff-comparison-1234a1234.png
Edit: It also pains me that this is not the default (or one of the two default) diff views almost anywhere. The best diff I've used was in Phabricator. But Google, Github and Git don't have a support for side-by-side diffs, which I'd argue are the best view in 90% of incremental changes.
git difftool --no-prompt --extcmd icdiff "$@"
So you can use 'git icdiff' to get the icdiff display.In general, you can use git-difftool in conjunction with your diff displayer of choice.
git difftool --color-words
ediff will also work with SCM (git, svn, etc.) as well.
But I can use icdiff in a PuTTY session with a coloured xterm and get a sensible and clear diff comparison.
Thanks! I really appreciate this!
I enjoy using console vimdiff in PuTTY, because my configuration allows quick navigation without too much thought.
The accumulated time for starting vim can become annoying when iterating over many files. (I could investigate loading diff pairs into tabs if I was sufficiently bothered.)
Helpful .vimrc settings:-
Firstly, map some keys to navigate to preceding/successive differences...
" Next/ previous diff (analogous to j/k, use the same fingers)
nmap <F6> ]czt
nmap <F7> [czt
And some helper keys... " Diff update, i.e. repaint the screen when needed
nmap <F5> :diffupdate<CR>
" Get from Buffer 1/ 2/ 3/ 4
nmap <F1> :diffget 1<CR>
nmap <F2> :diffget 2<CR>
nmap <F3> :diffget 3<CR>
nmap <F4> :diffget 4<CR>
Configure all visible windows when starting via vimdiff or diffthis. I prefer no folding (for added context) and then to navigate with the above keys. " Apply window-local settings to all diff windows
au! FilterWritePost * if &diff | set wrap | set foldcolumn=0 | set nofoldenable | endif
Finally, set some colors... " Override the diff colours
highlight DiffAdd term=reverse cterm=NONE ctermbg=darkblue ctermfg=white
highlight DiffDelete term=reverse cterm=NONE ctermbg=black ctermfg=blue
highlight DiffChange term=reverse cterm=NONE ctermbg=darkgray ctermfg=white
highlight DiffText term=reverse cterm=bold ctermbg=brown ctermfg=white
Not implemented here is a toggle to ignore whitespace changes (perhaps mapped to <F8>).I mostly use GitGutter, a Sublime Text plugin that puts a symbol in the "gutter" (line numbers column) to indicate which lines changed, where one was deleted or where one was added. It works only on git repositories, though.
A gutter symbol would be an option, though.
Bold text might also be an option, though it wouldn't immediately distinguish between added and removed characters.
I use meld for GUI and noticed it's not 100% accurate, sometimes they can not tell if two files are different, which is odd.
Have I miseed something?
edit: fix typo
As for using emacs, there are many cases when I want a stand-alone diff tool.
It's just coloring the standard diff output so lines starting with > or + are yellow and ones starting with < or - are green. This is also what "git diff" does by default: http://www.jefftk.com/git-diff-color-2x.png
icdiff is doing a side-by-side diff, and it's only coloring the changed sections of lines: http://www.jefftk.com/icdiff-side-by-side-2x.png
Example: http://i.imgur.com/smubTnH.png
(works with repositories; not a general diff replacement.)