Configuring Eclipse to Highlight Changed Lines Compared to Git Commit

Eclipse is one of the good IDEs for C/C++ projects with its great source code indexer. It is common the source code version is controlled by some tools like Git for software projects. It is convenient if the IDE can show the current changes compared to the committed code version. In this post, we will introduce how to configure Eclipse to show the changes of the source code files compared to the committed Git revision for Git projects.

Configure Eclipse code editor to highlight changed lines compared to Git commit

From menu Window -> Preferences, open the Eclipse Preference dialog.

In the Eclipse Preference dialog, choose General -> Editors -> Text Editors -> Quick Diff, and changes the options.

First, make sure enabling Enable quick diff.

Then, in the “Use this reference source”, choose A Git Revision.

Then the code changes compared the commit in Git is shown (e.g. lines 144-146, 160-161).

Show changes types with ‘+’/’~’ characters

We can also make Eclipse show the types of changes for the changed lines by making Eclipse show a character before the changed lines.

To enable this feature, in the Preference Dialog -> General -> Editors -> Text Editors -> Accessibility page, enable the Use characters to show changes in the vertical ruler.

Then the ‘+’ (for added lines) or ‘~’ (for modified lines) characters will be shows to indicate the kinds of changes of those changed lines.

Leave a Reply

Your email address will not be published. Required fields are marked *