Vim diff
I was digging through Vim's documentation, and came across the help article
diff.txt
. It turns out that Vim implements a visual diff feature, which shows
the 'difference between two to eight versions of the same file'.
I occasionally need to find the differences between two files, and have
historically used diff
for this. Unfortunately, I find the output quite hard
to parse:
$ diff file_1 file_2
32c32
< TODO: screenshot of diff
---
> ![Image showing what a diff looks like in Vim][vim-diff]
41a42,43
>
> [vim-diff]: /img/posts/vim-diff/diff.png
Vim's visual diff is much clearer to me:
$ vim -d file_1 file_2
Vim sets some options to make browsing the diff easier:
scrollbind
is set toon
, so when you scroll through one file, the other will scroll alongside it- Sections of common text are hidden with a fold
There are commands for jumping between diffs, and copying text from one file to
the other. You can find out more by typing :help diff.txt
from inside Vim.