如何在 Visual Studio 2010 中比较两个文件?

发布于 2024-12-08 12:22:51 字数 264 浏览 3 评论 0原文

在 Visual Studio 2010 中,是否有内置方法或免费插件可以打开两个选定文件的文件比较?

理想情况下,我希望能够在解决方案资源管理器中选择两个文件,右键单击其中一个,然后显示一个选项来比较这两个文件(在并排比较工具中)。

我知道 Visual Studio 比较工具,但我的理解是它在 Visual Studio 2010 下不起作用。

In Visual Studio 2010, is there a built-in way, or a free add-on that can open a file comparison for two selected files?

Ideally, I'd like to be able to select two files in the Solution Explorer, right click on one of them, and be presented an option to compare the two files (in a side-by-side diffing tool).

I'm aware of Visual Studio Comparison Tools, but my understanding is that it does not work under Visual Studio 2010.

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

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

发布评论

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

评论(2

骷髅 2024-12-15 12:22:51

您可以使用这样的宏来调用您选择的 diff 程序:

Sub DiffTwoSelectedFilesOrCrash()
    DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()

    Dim items As SelectedItems = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).DTE.SelectedItems
    If items.Count = 2 Then
        Dim path1 As String = items.Item(1).Collection.Item(1).ProjectItem.FileNames(1)
        Dim path2 As String = items.Item(1).Collection.Item(2).ProjectItem.FileNames(1)

        Dim diffProgram As String = "C:\Program Files\SourceGear\DiffMerge\DiffMerge.exe"
        Dim p As System.Diagnostics.Process = New System.Diagnostics.Process()
        p.Start(diffProgram, path1 + " " + path2)

    End If
End Sub

然后您可以通过“工具”->“指定键盘快捷键来运行宏”。选项->键盘。

You can use a macro like this to call a diff program of your choice:

Sub DiffTwoSelectedFilesOrCrash()
    DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).Activate()

    Dim items As SelectedItems = DTE.Windows.Item(Constants.vsWindowKindSolutionExplorer).DTE.SelectedItems
    If items.Count = 2 Then
        Dim path1 As String = items.Item(1).Collection.Item(1).ProjectItem.FileNames(1)
        Dim path2 As String = items.Item(1).Collection.Item(2).ProjectItem.FileNames(1)

        Dim diffProgram As String = "C:\Program Files\SourceGear\DiffMerge\DiffMerge.exe"
        Dim p As System.Diagnostics.Process = New System.Diagnostics.Process()
        p.Start(diffProgram, path1 + " " + path2)

    End If
End Sub

You can then assign a keyboard shortcut to run the macro, via Tools -> Options -> Keyboard.

神魇的王 2024-12-15 12:22:51

您尝试过 Devarts 代码比较吗? 此处有一个免费版本。免费版本确实有一些限制,但它可能包含您需要的所有内容(另请参阅功能矩阵< /a>)。请参阅该网站了解更多信息。

您可以并排查看代码块或文件并查看差异(见下文)。
在此处输入图像描述

它还可以让您使用>>同步差异。如图所示的按钮。

Have you tried Devarts Code Compare? There is a free version here. The free version does have some limitations but it may include everything that you need (also see the feature matrix). See the site for more info.

You can look at code blocks or files side by side and see the differences (see below) .
enter image description here

It will also let you synchronize the differences using the >> buttons shown in the image.

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