Skip to Content
Author's profile photo Thomas Fiedler

Customize Syntax Coloring in ABAP in Eclipse

Syntax coloring is a nice feature every ABAP developer loves since the new ABAP editor was provided a couple of years ago.

But you can only use it to distinguish between keywords, non-keywords, literals and comments. But keywords are all colored the same way in the ABAP editor. 


In Eclipse you have much more possibilities to customize the color settings of the keywords in the editor. With the new ADT version 2.58 it is possible to specify the keyword colors via the eclipse preferences page:


01-04-2016 15-12-14.png



In the example above I specify that “Method” and “Endmethod” statements are colored differently in the editor than the other keywords. I can even specify different font settings for these keywords, e.g. I could strikethrough FORM statements. The code then looks like this:



01-04-2016 15-16-32.png


Have fun with your colored code.


Regards,

Thomas.




Assigned Tags

      14 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Raghu Govindarajan
      Raghu Govindarajan

      Thomas,

      Thank you for this post. I am currently on 2.58 and have been able to change my syntax highlighting and love it.

      I was looking at the version history at Version history for 2.60 link   and noticed that this was mentioned under the change log for version 2.60 and not 2.58. So, the question is, what really did change with version 2.60?

      Thanks,

      Raghu

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Raghu,

      with 2.60 we added the functionality to highlight method/endmethod blocks in the editor.

      23-05-2016 16-54-34.jpg

      Regards,

      Thomas.

      Author's profile photo Raghu Govindarajan
      Raghu Govindarajan

      Oh, nice... thank you, that really helps with screen readability on classes!

      Raghu

      Author's profile photo Former Member
      Former Member

      Hi Thomas,

      does this feature depend by the NW Backend Version?

      I'm on NW7.4 SP08 and installed ADT 2.60 on Eclipse Luna:

      ADT2.60.PNG

      But unfortunately i can't find this setting possibility within the preferences:

      ADT Preferences.PNG

      Cheers

      Eugen

      Author's profile photo Raghu Govindarajan
      Raghu Govindarajan

      Eugen Soydas - click the second link on the right side which says "Colors and Fonts", it should take you the page with the new settings.

      Raghu

      /wp-content/uploads/2016/06/2016_06_02_09_56_00_966749.jpg

      Author's profile photo Former Member
      Former Member

      I found the reason for my issue.

      As I mentioned, i'm running on Eclipse Luna. But my mistake was, that i downloaded ADT2.60 from the Update-Site for Mars.

      A colleague of mine runs Eclipse Mars, we installed the plug-in on his system and he has this settings now at the same area within the preferences as thomas descriped above.

      However, thanks for your reply.

      Cheers

      Eugen

      Author's profile photo Christian Guenter
      Christian Guenter

      Hi Thomas,

      nice feature. I found some quirks on my installation.

      1) I switched syntax coloring for the data keyword on. It seems that it doesn't work for inline declarations.

      2016-06-25 23_16_46-workspace - ABAP_2 - Global Class ZCL_ALV_REPORTING_VIEW [DVE] - active, locked .png

      2) If i try it for field-symbol(s) it looks like this

      2016-06-25 23_19_34-Preferences.png

      2016-06-25 23_23_40-workspace - ABAP_2 - Global Class ZCL_ALV_REPORTING_VIEW [DVE] - active, locked .png

      3) and if i activate it for select, select-options are also considered.

      2016-06-25 23_27_11-workspace - ABAP_2 - Program Z_TEST_TEMPLATE [DVE] - active - DVE_010_guenterc_e.png

      Is this behaviour intended, maybe you can explain it?

      Regards Christian

      P.S. I use the latest ADT version

      2016-06-25 23_28_55-About Eclipse Features.png

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Christian,

      thanks for the feedback. I just checked my internal client and it is seams that the bugs are already fixed. So you can expect the correct behavior with the next patch of ADT.

      Regards,

      Thomas.

      Author's profile photo Pavel Astashonok
      Pavel Astashonok

      I have the latest ADT plugin (2.68) but the syntax coloring doesn't work, only basic color rules are applied. Does there any priority? Where should I search too fix it?

      Author's profile photo Stefan Rutzmoser
      Stefan Rutzmoser

      Hello Thomas,

      what about adding regular expressions for styling? Then we could remove the coloring of "METHOD" in CALL METHOD, but keeping it at the beginning of a METHOD block. I know that CALL METHOD is old-fashioned, but much of the written code is it, too.

      I think about something like Indesign's GREP-Styles:

      https://www.publishingblog.ch/indesign-hoch-und-tiefstellungen-mit-einem-grep-stil-automatisieren/

      Best Regards,

      Stefan

      Author's profile photo Harald Wilde
      Harald Wilde

      is it possible to set different background colors in the abap-editor for writable mode compared to read-only?

       

      Author's profile photo Thomas Fiedler
      Thomas Fiedler
      Blog Post Author

      Hi Harald,

      no, this is not possible. Maybe a nice extension to the editor. I will talk with my development experts about it.

       

      Regards,

      Thomas.

      Author's profile photo Harald Wilde
      Harald Wilde

      Not my Idea. Taken over from the ABAP-Workbench Editor.

      • Your eyes do not need to jump to the status bar every time you open an editor tab.
      • Would make it a little easier for abap-workbench programmers to switchover to eclipse.

       

      Author's profile photo Ravi Singh
      Ravi Singh

      Hi @Thomas

      I am using Eclipse 2021-06 with latest version of ADT installed.

      I used * to change the color of all the keywords (to say PEACH color). Most of the keywords got changed to PEACH, but there seems to be bugs.

      While DATA shows in PEACH, @DATA still showing in default color. Even explicitly putting DATA keyword as Peach, doesn't have any effect on @DATA.

      Similar issue with WITH keyword. It just doesn't change it's color whatever I try.

      FIELD-SYMBOL & NO-GAPS also didn't change its color through *, but explicitly putting FIELD-SYMBOL and NO-GAPS as a keyword changed color.

      There may be more bugs but that's what I have found till now. 

      Can you get these issues corrected in next version of ADT or let me know where I can file these as bugs.

      Thanks,

      Ravi

       

       

      My%20Current%20Keyword%20color%20config

      My Current Keyword color config