File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes IDEs, Version Control and other tools and the fly likes Eclipse editor - arbitrary text highlighting Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » IDEs, Version Control and other tools
Bookmark "Eclipse editor - arbitrary text highlighting" Watch "Eclipse editor - arbitrary text highlighting" New topic
Author

Eclipse editor - arbitrary text highlighting

frantisek nejedly
Ranch Hand

Joined: Sep 09, 2008
Posts: 42
Hi everyone,

I'd like to know if there's a way to change background colour of any arbitrary text inside the Eclipse 3.4.0 Java Text editor.

Thanks,
T.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

Have a look at Window / Preferences, General / Appearance / Colors and Fonts, and Java / Editor / Syntax Coloring (for Java-specific settings).


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
frantisek nejedly
Ranch Hand

Joined: Sep 09, 2008
Posts: 42
Thanks a lot Jesper,

I am sorry but there is not what I want. Or I don't see it.
Basically I would like to set background colour of any text in a code(e.g. a part of a method), something which works e.g. in MS Word.
But it may not be possible in Eclipse editor.

Thank you once again,
T.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

So, you mean you want to select some text in any kind of file that you've opened in Eclipse, and highlight an arbitrary part of the text (and keep it highlighted)?

As far as I know, Eclipse doesn't support that.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38835
    
  23
I had a look in Eclipse earlier. You can get different text colours or font attributes for all sorts of things, but background colour wasn't among the attributes.
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10375
    
    8

Actually you can choose the background color for "occurrences". I use it regularly.
However I cannot find it where you define the color. Doh!
Most probably its under some editor property.


[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
frantisek nejedly
Ranch Hand

Joined: Sep 09, 2008
Posts: 42
Mark Occurrences Colour (Preferences/Java/Editor/SyntaxColoring) can be used only for selected elements like a variable, method, type or other element, and as Campbell says, there is no background change option there.

Using of background colour seems to me very useful, helps make the code more evident. Apparently the Eclipse editor doesn't support this.

Thanks a lot to all of you.
Jesper de Jong
Java Cowboy
Saloon Keeper

Joined: Aug 16, 2005
Posts: 14150
    
  18

Maybe this comes close to what you want to do:

You can set bookmarks on lines in the Eclipse editor. Right-click on the left margin of the line and select "Add Bookmark...". You can now give the bookmark a description.

Select Window / Show View / Other..., then General / Bookmarks to open the Bookmarks view. There you can quickly jump to a bookmark by double-clicking on it.
frantisek nejedly
Ranch Hand

Joined: Sep 09, 2008
Posts: 42
Thank you, the bookmarks seem to be useful.

What I in fact need is to be able to mark clearly a part of code I have lately changed or added. Sure, I can use comments but that's not the best way, if I could use background colour, the code remains untouched and I can distinctly see the spot of changes/additions.
Any idea?
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
How about Eclipse's Local History?

Right click on the source file, Compare With->Local History.
You can even restore from Local History! Each save is added to the History.
This feature is available in Eclipse 3.3.0 and should be available in prevous versions too.

To get an instant taste of what this is like check here

See if this suits your requirements.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38835
    
  23
Sounds like a candidate for transfer to the IDEs forum . . . wheeeeeeeee!
frantisek nejedly
Ranch Hand

Joined: Sep 09, 2008
Posts: 42
Gamini, Eclipse's Local History is fine. I didn't know about since I'm new in Java and in Eclipse as well.
Thanks a lot.
Gamini Sirisena
Ranch Hand

Joined: Aug 05, 2008
Posts: 347
You are welcome. Glad to be of help.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16061
    
  21

There's also some options you can switch on in the Preferences for general editing that will indicate changes.


Customer surveys are for companies who didn't pay proper attention to begin with.
Emilio Lb
Greenhorn

Joined: Aug 05, 2010
Posts: 2
To do this, I use bookmarks:

* Define in Editor preferences, highlight for bookmarks
* Define a shorcut for define bookmark, for example Ctrl+shift+I

To highlight some text, select it, then Ctrl+shift+I, and, it will become highlighted. To remove the colour, remove the bookmark with right click.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Eclipse editor - arbitrary text highlighting