如何让 vimdiff 显示 cvs diff --side-by-side 的输出

发布于 2024-08-04 01:32:53 字数 672 浏览 2 评论 0原文

CVS diff 可以选择并排显示修订版本,并用常用的补丁符号表示差异,例如:

import zlib                                        import zlib
                                                 > import time
import traceback                                   import traceback

import cElementTree as ElementTree                 import cElementTree as ElementTree

from util import infopage                          from util import infopage
                                                 > from util.timeout import Timeout

是否有办法将该输出通过管道传输到 vimdiff,以便它在两个并排缓冲区中显示这两列以及所有差异 -强调 vimdiff 的优点?

我知道像 cvsvimdiff.vim 之类的工具,但这些工具的问题是它们一次只能处理一个文件,而 cvs diff 输出列出多个文件。

CVS diff has the option to display revisions side by side and denote diffs with usual patch symbols like:

import zlib                                        import zlib
                                                 > import time
import traceback                                   import traceback

import cElementTree as ElementTree                 import cElementTree as ElementTree

from util import infopage                          from util import infopage
                                                 > from util.timeout import Timeout

Is there anyway to pipe that output to vimdiff so that it displays those two columns in two side-by-side buffers along with all the diff-highlighting goodness of vimdiff?

I'm aware of tools like cvsvimdiff.vim and the like, but the problem with those is that they only work on one file at a time, whereas the cvs diff output lists multiple files.

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

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

发布评论

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

评论(2

完美的未来在梦里 2024-08-11 01:32:53

一旦 Vim 缓冲区中有该文本,您就可以轻松地将其拆分为两个缓冲区。看起来您的示例输入以 50 个字符进行分割。

因此,使用 视觉块突出显示差异的一半,剪切它,将其粘贴到新缓冲区中,删除尾随空格和 > 分隔符,就这样吧。或者编写一个函数来执行此操作,如下所示(假设拆分始终为 50):

function! SplitCVSDiff()
    exe "norm gg_\<C-v>51\<Bar>Gd:vnew\<CR>p"
    silent! %s/\v\s+(\> )?$//
endfunction

可能需要变得更加健壮,我不熟悉 CVS 使用的输出的确切样式。不过应该不难。

Once you have that text in a Vim buffer, you can easily split it into two buffers yourself. Looks like your sample input does the split at 50 characters.

So use <C-v> to visual-block highlight half of the diff, cut it, paste it in a new buffer, remove trailing whitespace and the > separator characters, and there you go. Or write a function to do it, something like this (which assumes the split is always at 50):

function! SplitCVSDiff()
    exe "norm gg_\<C-v>51\<Bar>Gd:vnew\<CR>p"
    silent! %s/\v\s+(\> )?$//
endfunction

Might have to be made more robust, I'm not familiar with the exact style of output CVS uses. Shouldn't be hard though.

请持续率性 2024-08-11 01:32:53

我会写一个脚本说:vimdiff_cvs file.cc
其作用是:

  1. 在本地存储 file.cc 的差异,删除它,更新到存储库。现在将其复制为 ~/.vimdiff/file.cc.repo。
  2. 通过应用补丁来恢复file.cc
  3. 调用vimdiff file.cc ~/.vimdiff/file.cc.repo。

I would write a script say : vimdiff_cvs file.cc
which does this:

  1. Store diff of file.cc locally, delete it, update to repository. Now copy it as ~/.vimdiff/file.cc.repo.
  2. Restorefile.cc by applying the patch
  3. Call vimdiff file.cc ~/.vimdiff/file.cc.repo.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文