vimdiff 作为合并工具

发布于 2024-08-16 11:36:22 字数 229 浏览 3 评论 0原文

vimdiff 有助于以图形方式显示两个文件的差异,并允许我们从左到右/从右到左选择更改。
我正在处理的文件是巨大的文件,除了少数之外,大多数差异 vimdiff 报告都可以自动合并。因为在 vimdiff 中逐个比较并采取操作需要花费大量时间。

我想知道 vimdiff 中是否有一个选项可以自动合并左右文件中的差异,只要没有歧义,并保留类似于 svn merge 和 cvs merge 工具的冲突解决方案?

vimdiff helps in showing the diff of two files graphically and allows us to pick the changes from left to right/right to left.
The files I am dealing with are huge files and most of the differences vimdiff reports can be auto-merged except a few.As it takes lot of time to go diff by diff in vimdiff and take the action.

I would like to know if there is an option available in vimdiff that automerges the differences in left and right files as long as there is no ambiguity and leaving the conflicted resolutions similar to the tools svn merge and cvs merge tools does?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

椒妓 2024-08-23 11:36:22

除非我们有一个基本副本,其中这两个文件分支并分别完成更改,否则不可能自动合并两个文件中的更改。如果某个item在一侧而另一侧没有,则无法判断该item是新添加的还是已存在的item被删除。由于合并存储库中的文件时存在基本副本,因此 cvs merge、svn merge 可以自动合并更改。

Its not possible to auto-merge the changes in two files unless we have a base copy where these two files branched and changes done separately. If an item is on one side and not on the other,it can't judge whether this item was newly added or an existing item was deleted. As there is a base copy exists while merging files in a repository, cvs merge,svn merge can auto-merge the changes.

寒江雪… 2024-08-23 11:36:22

如果您不使用版本控制,您可以尝试以下方式比较和修补:

  1. 在更改文件(例如 file.txt)之前,备份原始版本(file.orig)。
  2. 进行更改后,制作补丁文件: diff file.orig file.txt >patch.txt
  3. 获取要合并更改的文件(例如 file2.txt)。
  4. 使用补丁: patch file2.txt patch.txt

更改将被合并,冲突的行将被放置在单独的文件中。

If you use no version control, you can try diff and patch this way:

  1. Before changing your file (say, file.txt), make a backup of the original version (file.orig).
  2. When changed are made, make a patch-file: diff file.orig file.txt >patch.txt
  3. Get a file which you want to merge changes to (say, file2.txt).
  4. Use patch: patch file2.txt patch.txt

Changes will be merged, conflicted rows will be placed in a separate file.

疯狂的代价 2024-08-23 11:36:22

看起来 vimdiff 不允许这样做。手册页显示
“vimdiff - 使用 Vim 编辑文件的两个或三个版本并显示差异”

但是您可以查看 Kdiff3 可让您进行比较和合并。

Looks like vimdiff does not allow that. Man page says
"vimdiff - edit two or three versions of a file with Vim and show differences"

But you can have a look at Kdiff3 which lets you compare and merge.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文