

Using Diffs in Vim
source link: https://jdhao.github.io/2021/10/24/diff_in_vim/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Using Diffs in Vim
Diff can be used to
compare two versions of the same file to find the changes. If you use vim, you
can use vimdiff
to compare files:
vimdiff file1 file2
Actually vimdiff is just a wrapper around vim executable, you can do the same
thing with vim using option -d
:
vim -d file1 file2
So neovim just removed this bloat. To compare two files using neovim, run:
nvim -d file1 file2
Previously, Vim has been using external diff tool for file diffs, since patch 8.1.0360, it beganto use libxdiff, which is much faster and has more features.
According to discussion here, libxdiff is also used as a
basis by Git as its internal diff library, that is when you use git diff
inside a git repository.
Since this commit,
the vim patch has been ported to neovim too. You can activate the internal diff
algorithm by update option diffopt
:
set diffopt+=internal
The default diff algorithm is myers diff. Other supported diff algorithm is:
algorithm:{text} Use the specified diff algorithm with the
internal diff engine. Currently supported
algorithms are:
myers the default algorithm
minimal spend extra time to generate the
smallest possible diff
patience patience diff algorithm
histogram histogram diff algorithm
So to use histogram diff, add the following setting:
set diffopt+=algorithm:histogram
References
Recommend
-
67
What's New in PHP 7.3 in 30 Seconds in Diffs 2 min Thu, Aug 16, 2018...
-
62
People who have worked with Phabricator using a ‘stacked diff’ workflow generally love it and seek it wherever they next go. People who have never used it and only...
-
9
December 17, 2020 Engineering Commits are snapshots, not diffs G...
-
6
Day 33: pairing is magic and beautiful git diffs • rc-2020 • a silly Rails login bug (or: pairing is magic) On Wednesday morning suddenly I wasn’t able...
-
5
Getting colored diffs out of SVN (Subversion)October 16, 2009 · 1 min read · Edit on Gi...
-
9
Published October 26, 2020 #packagemangers, #npm,
-
7
Extracting Diffs from Git with PythonMay 6, 2016 · 2 min · Benjamin BengfortOne of the first steps to performing analysis of Git repositories is extracting the changes over time, e.g. the Git log. This seems like it s...
-
5
Improving performance on complex diffs May 19, 2022 3 min read Share Bitbucket Cloud i...
-
2
Brought to you by This week we’re peeking into the future again — this time we’re looking at the future of modern code review and workflows around pull requests. Jerod and Adam were jo...
-
4
Leveraging 'shot-scraper' and creating image diffs October 23, 2022 A little while ago Simon Willison introduce...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK