在 Eclipse 中突出显示修改过的行
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2447146/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Highlighting modified lines in Eclipse
提问by Sudar
In netbeans, if I open a file which is under version control the lines which are modified are highlighted in the left. (green for new lines and blue for modified lines)
在 netbeans 中,如果我打开一个受版本控制的文件,修改过的行会在左侧突出显示。(绿色代表新行,蓝色代表修改行)
Is it possible to get a similar effect in Eclipse?
是否有可能在 Eclipse 中获得类似的效果?
回答by Dan Allen
- Open the Preferences window
- Search for "diff"
- Select Quick Diff
- Change the "Use this reference source" to a SCM provider (like CVS, SVN or Git)
- 打开首选项窗口
- 搜索“差异”
- 选择快速差异
- 将“使用此参考源”更改为 SCM 提供程序(如 CVS、SVN 或 Git)
By default, it compares to the latest version on disk, which, if you've saved the file, is no diff at all. You have to activate the comparison against a SCM repo. I'm not sure what happens if you more than one type of SCM since this is only a single selection.
默认情况下,它与磁盘上的最新版本进行比较,如果您保存了文件,则完全没有差异。您必须激活与 SCM 存储库的比较。我不确定如果您使用多种类型的 SCM 会发生什么,因为这只是一个选择。
回答by thSoft
With Subversive, you can do Team > Show Annotations, and it will annotate the lines with the author and date of the last modification of that line.
使用 Subversive,您可以执行 Team > Show Annotations,它将用作者和该行最后修改的日期来注释这些行。
回答by Hakim
Right-click
on the file > Team
> Show annotation
.
A brown
tape will appear on the left-side of the code (it represents commited
lines), and the modified
lines will be shown in white
.
Right-click
在文件 > Team
> 上Show annotation
。代码左侧将出现
一条brown
胶带(它代表commited
线条),modified
线条将显示在 中white
。
回答by Vinit Solanki
In Eclipse by using its Quick Diff feature. This is easy to do:
在 Eclipse 中使用它的 Quick Diff 特性。这很容易做到:
- Go to Window -> Preferences -> General -> Editors -> Text Editors -> Quick Diff. This is the dialog from where it can be configured.
- Turn on Quick Diff, by enabling the option
Enable quick diff
. - Choose the version control system for which Quick Diff is needed
from the dropdown
Use this reference source
. Git, SVN and CVS should be present here. Mercurial appears if the MercurialEclipse plugin is installed. - The overview ruler is the ruler to the right of the scrollbar in the
editor. If you would like to see the uncommitted lines to be marked
on it, enable the option
Show differences in overview ruler
. - Choose Apply and OK. Close all editor windows and reopen the source file that you want in the editor.
- 转到窗口 -> 首选项 -> 常规 -> 编辑器 -> 文本编辑器 -> 快速差异。这是可以配置它的对话框。
- 通过启用选项打开 Quick Diff
Enable quick diff
。 - 从下拉列表中选择需要 Quick Diff 的版本控制系统
Use this reference source
。Git、SVN 和 CVS 应该出现在这里。如果安装了 MercurialEclipse 插件,就会出现 Mercurial。 - 概览标尺是编辑器中滚动条右侧的标尺。如果您想看到未提交的行被标记在上面,请启用选项
Show differences in overview ruler
。 - 选择应用和确定。关闭所有编辑器窗口并在编辑器中重新打开所需的源文件。
You should be able to see the newly added, modified or deleted lines marked in colors in the left bar on which line numbers are usually displayed. The colors used are the ones set in the Quick Diff dialog (see above steps). You can also view these uncommitted locations marked along the overview ruler on the right.
您应该能够在通常显示行号的左侧栏中看到以颜色标记的新添加、修改或删除的行。使用的颜色是在 Quick Diff 对话框中设置的颜色(请参阅上面的步骤)。您还可以查看沿右侧概览标尺标记的这些未提交位置。
回答by ultra
EGit plugin's Quick Diff does exactly the same as netbans modified lines feature.
EGit 插件的 Quick Diff 与 netbans 修改行功能完全相同。
回答by David Avendasora
There are at least two thingsyou must do to get revision-based change highlighting (i.e., ones that do notdisappear when the file is saved) to show up in Eclipse's "overview ruler" when using Git:
有至少两件事情你必须做的就是根据修订修改高亮(即那些没有当文件被保存消失)在Eclipse中的“概述统治者”使用Git时出现:
- Prior to import, make sure that
Preferences
>Team
>Git
>Projects
>Automatically Share project that are located inside Git repositories
is checked orimport the project into your workspace usingImport...
>Git
>Projects from Git
(as pointed out by @cornelius in a comment on another answer) - Enable Quick Diff and select "A Git Revision" as the reference source:
Preferences
>Editors
>Text Editors
>Quick Diff
- 在导入之前,请确保选中
Preferences
>Team
>Git
>Projects
>或使用> >将项目导入到您的工作区中(正如@cornelius 在对另一个答案的评论中指出的那样)Automatically Share project that are located inside Git repositories
Import...
Git
Projects from Git
- 启用 Quick Diff 并选择“A Git Revision”作为参考源:
Preferences
>Editors
>Text Editors
>Quick Diff
回答by prime
For Eclipse Version: 2019-03 (4.11.0)Go to
对于Eclipse 版本:2019-03 (4.11.0)转到
- Select 'window'
- Select 'Preferences'
- Go to General -> Editors -> Text Editors -> Quick Diff
- Tick 'Enable quick diff'
- Tick 'Show differences in overview ruler'
If you want to keep the changes after you save your local copy, then you need to tell the eclipse to compare the local copy with the repository version. To do that change the
reference source
accordingly.
回答by GuruKulki
In eclipse too you will get the line highlighted which is changed util you save the file. and highlight is nothing but the change in color at the left panel of the editor before the start of that changed line.
在 eclipse 中,您也会突出显示该行,该行已更改 util 您保存文件。和突出显示只不过是在更改行开始之前编辑器左侧面板上的颜色变化。