如何让 vimdiff 显示 cvs diff --side-by-side 的输出
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
一旦 Vim 缓冲区中有该文本,您就可以轻松地将其拆分为两个缓冲区。看起来您的示例输入以 50 个字符进行分割。
因此,使用
视觉块突出显示差异的一半,剪切它,将其粘贴到新缓冲区中,删除尾随空格和>
分隔符,就这样吧。或者编写一个函数来执行此操作,如下所示(假设拆分始终为 50):可能需要变得更加健壮,我不熟悉 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):Might have to be made more robust, I'm not familiar with the exact style of output CVS uses. Shouldn't be hard though.
我会写一个脚本说:vimdiff_cvs file.cc
其作用是:
I would write a script say : vimdiff_cvs file.cc
which does this: