Eclipse IDE Scope Highlighting? - java

When I first learned Java, I was using an IDE called "BlueJ." It had this feature called "Scope Highlighting" which made it very easy to read blocks of code. Now I've moved on from BlueJ and began using Eclipse. I'm currently in the process of customizing Eclipse to my liking and would like this Scope Highlighting feature inside Eclipse.
I've searched everywhere for an answer on how to do it but I cannot find any information pointing to a solution for doing it in Eclipse.
Here's a picture to demonstrate what Scope Highlighting looks like:

I think the best option for you is EditBox, a scope highlighting plugin for Eclipse:
http://editbox.sourceforge.net/

I'm afriad that closest you can get is Shift + Alt + arrow_up
It is selecting wider block of code. pressing this few times will give you very similar result to what you are searching for. I use it often.. it is useful, also for refactoring.
EDIT: As #j2emanue said: you can just double click the delimiter (like a bracket) and it will highlight the entire scope.

you can use Shift + Alt + arrow_up but many people dont realize you can just double click the delimiter (like a bracket) and it will highlight the entire scope. Try double clicking your if statements bracket for example and watch eclipse highlight the entire scope. It works with any delimiter. so you can use parenthesis as well.
as a side note: if your using intelliji checkout this plugin works great: https://github.com/izhangzhihao/intellij-rainbow-brackets#screenshots

This isn't exactly what you're after but you can put your cursor in a method and then click the Show Source Of Selected Element only button on the toolbar. Your editor gets reduced to just that method. Click again and your back to your entire file.

I doubt eclipse does have the same function as blue j.The best advise I can give you, is to change your theme to your liking which would enable you to easily select and highlight the block of code...and to customise your theme , go to http://eclipsecolorthemes.org/. ....
If you still have a problem, go to http://codejava.co.uk/contact.html and send your email.you can create a dummy one if want, then I will send you XML files I use for my eclipse themes.

can Bracketeer do this ? its an eclipse plug in ..
http://marketplace.eclipse.org/content/bracketeer-java-jdt#.UK6sY4fAdLc

Maybe you will also like the VSCode extension "Blockman". It highlights nested code blocks based on curly/square/round brackets, html/xml tags and Python/Yaml indentation. (I am the author of Blockman).
.
https://i.ibb.co/31F0rm9/vscode-blockman-intro-leodevbro-extension3.png
.
.

Related

Is it possible to tweak the settings so it automatically places quotations when using System.out.println()?

I am using java on Intellij and I wonder if it is possible to make it so that it automatically places quotations System.out.println(here);
Thanks
Yes, it is possible.But a bit tedious. (EDITED)
ECLIPSE
you need to know that Ctrl+space opens options for autofill.
you need to create a simple template at
Window>Preferences>Java(dropping menu)>Editor>Templates>New...
In the open window at Name type: Syso
at Pattern: System.out.println("")
Make sure the checkbox Automatically insert is on.
Apply and close
Now every time you type Syso and hit Ctrl+Space there will be first option
of autofill with quotations. Profit.
oof, didn't notice about Intellij , my bad. Thought about Eclipse. Well here is one for Intellij
INTELLIJ
I believe the Intellij version of cntl+space is Tab button
Go to Settings>Editor>Live Templates
Pick any template and press Plus icon. Choose Live Template
In abbreviation type your desired word (I would put: Syso)
In Template txt type : System.out.println("")
Make sure the box with Reformat according to style is checked
Now every time you type Syso you can hit Enter and have PROFIT!

Intellij change "first suggested fix" key?

I can't find the KeyMap entry for changing the default AltShiftEnter to apply the first selected fix (in Java code) for a problem in Intellij.
See this screenshot:
I think the combination is too difficult (I'd like to use one hand and max two fingers) and want to change it to Eclipse's Ctrl1
How to change this?
There is related request on YouTrack: https://youtrack.jetbrains.com/issue/IDEA-217465
As a workaround you could put caret on red code, press "Alt+Enter" and select suggestion with arrow keys.

Intellij: How can I wrap a piece of text in Javadoc?

So, for example, if I were to insert a Javadoc comment for a field from some external source on web, I would copy paste the relevant part from the website and then move on to my Class to incorporate the copied content as a Javadoc comment for the field.
But the problem is, I can't find any support from Intellij regarding this. Currently, I have to type, /** + Enter to generate a stub then paste the content there, which doesn't get properly pasted - I mean, a paragraph of 5 lines comes as a single long line and the Javadoc * on the side disappears.
I was looking for something like, paste the content copied raw in the place then select it and if Intellij provides some shortcut to wrap it as a Javadoc comment, do it except I couldn't find any support from Intellij for this approach.
So my question is, does anyone know of any such tool/plugin/built-in Intellij support or any other workaround for doing this as this is time consuming?
You will have to start with the /** and Return to get the basic javadoc comment. Then you can paste your text with ctrl+V (⌘+V on OSX) as the cursor is positioned at the right place.
All that is left then is use the keyboard shortcut that is defined for reformatting. In the menu you will find that under _Code/Reformat Code, on my Mac it is ⌘+⌥+L.

remove indentation in source code

I use Eclipse IDE and Window Builder Pro for create window.
When I go to the source code I see a big indent text. How to delete ?
How about good old Shift + Tab?
If by "how to delete" you mean to say that you want to decrease the indentation level, try this:
Go to
Window->Preferences->general->Editors->Text
Editors
There specify the indentation level under :
Displayed Tab Width.
Additionally you can customize you formatting in Eclipse as :
Go to
Window->Preferences->Java->Code
Style->Formatter
Select the formatter and press Edit. Use whatever suits you.
Then Select the text you want to format and press Ctrl+Shift+F
If you want to fix indent only you can select lines and press Ctrl-I.
Take a look at Eclipse keys
Most likely you insert tab character which is being expanded to 8 positions in target IDE.
Change setting in Eclipse to insert 4 spaces (or whatever your style is) when tab is pressed.
Then you can try to reformat your file in Eclipse. Also, you can use sed to replace \t with 4 spaces.
If you like the way your formatter is set up for the rest of your code, perhaps telling the formatter not to work on this section would be desirable. Then you can unindent the section to make it visually appealing and not worry about it changing formatting.
Linked solution works in Eclipse 3.6.

Improving Eclipse autocompletion?

Currently the Eclipse autocompletion seems only to be triggered after a dot or on parameters, I want to use it for variables too, e.g. if I have
String test="hello";
then I want the autocompletion to suggest "test" if I start typing "t" in the next line (e.g. if I intent to change the value of the variable test).
Is there any Eclipse plugin capable of doing this? I already checked the Eclipse content assist options, but seems like there no option for what I want? Thanks for any hint!
First of all, thanks for all the replies. They are correct, however you have to press the key combination each time. Here's how it's done automatically:
That plug-in is not necessary any more. Just go to
Preferences > Java > Editor > Content Assist
and paste:
ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.
into the "Auto activation triggers for Java:" field.
This simply triggers auto activation after any English alphabet character and after dot.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=159157#c12
Works fine :-)
Hint: You probably want to additionally set the auto activation delay to 0, at least if you are used to visual studio ;-)
In addition to the suggestions above, did you try ALT + / it does incremental matching? No?
ctrl + space
If you press ctrl+space key combination, eclipse will show you the code assist window.
Type t and then hit ctrl+space, it will show you possible matches
You can press "t" and then Ctrl+Space..
is it?
In Eclipse
Window--->Preferences---> search for Content Assist under Content Assist go for Advanced
and check the Java Praposals.
done.

Categories