On Eclipse 2019-09 there is a very annoying "feature" which finds the wrong method when you are typing its name. The image below speaks for itself.
When I type "rem", it selects hasRemaining() and not remaining(). Also when I type "rem", of course remaining() should appear first and before should_remanage(). Is it possible to fix that?
Click here for the image
Go to Window > Preferences > Java > Editor > Content assist and you will find an option that let you select between relevance and alphabetically.
Also checkbox allow you to select camelcase matches 'show camel case matches' -
tune these properties to get expected results..
Related
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!
I'm using Checkstyle for Java in Eclipse IDE. I don't know in every java file, at second line, I always receive warning in Checkstyle : (although I'm pretty sure that I don't press tab key)
File contains tab characters (this is the first instance).
public class Percolation {
private boolean[][] grid;
...
}
When I have typed : public class Percolation {, press enter, Eclipse will make an indent for me, after that, I type private boolean[][] grid;. But, I still receive this warning.
Please tell me how to fix this. (I don't want to turn off this warning, because this is a must. Another people will check again my file).
Thanks :)
step 1 In eclipse, Preference > Java > Code Style > Formatter. Edit the Active profile.(If you don't wish to edit the built-in profile , create a new profile). Under "Active profile:" there is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy. Change the Tab Policy from Mixed to Space only & apply the changes.
step 2 Back to your Eclipse Perspective, navigate via the menu bar: Source > Format Element (not "Format") and save.
Run checkstyle you won't find "File Tab Character: File contains tab characters (this is the first instance)." warning anymore.
To visualize the difference by enabling whitespace character that you'll find in tool bar.
In eclipse, go to Preferences > General > Editors > Text Editors
and check the box for "Insert spaces for tabs". Then it will indent with spaces instead of tabs.
another possibility is find and replace:
- copy a tab
- Got to Find and Replace Window
find: paste the tab
replace: type 4 whitespaces (or number of whitespaces a tab consists of)
-> replaceAll
For Java code:
step 1 In eclipse, Preference > Java > Code Style > Formatter. Create a new profile and initialize it with default profile. There is a drop down dialogue box .. beside it, click "Edit..." which opens up the edit dialog box. Under the "Indention" tab, you'll find Tab Policy. Change the Tab Policy from Mixed to "Space only" & apply the changes.
step 2 Correct Indentation of your code by ctrl+I. It will replace Tab with Space.
To fix this Navigate to Preferences > Java > Code Style > Formatter.
Then click on New > give name for the formatter > click on ok.
Once you complete this step, on the automatically popped up window which is the formatter you created, click on indentation > tap policy > select space only.
Or if you come back later time you could click on edit and follow the same step.
in the indentation size I prefer to put 4 > click apply and close.
After that right click on the class file you want to format > source > format.
This will cause the indentation to be spaces instead of tabs.
I was also facing the problem but I got the solutions.
Step 1 : Go to Window > Preferences > Checkstyle.
Step 2 : In the right side You will see the Global Check Configurations. There you will find that Two configurations are available. Select the configuration with Eclipse and click on Set as Default button and click on OK.
Hope this will solve your problem.
For Java Editor
Click Window » Preferences
Expand Java » Code Style
Click Formatter
Click the Edit button
Click the Indentation tab
Under General Settings, set Tab policy to: Spaces only
Click OK ad nauseum to apply the changes.
For other editors refer here How do I change Eclipse to use spaces instead of tabs?
Simply fixed that style issue (triggered by scalaStyle) by removing TAB with SPACE indent :)
In eclipse, when your cursor is placed on a method (or other things), other places the method exists are highlighted. I'd like to change the color of this highlight, but after scouring the eclipse preferences many times in all 3 places, I have yet to find it.
Any of you Eclipse gurus know where to find this option?
After running around in the Preferences dialog, the following is the location at which the highlight color for "occurrences" can be changed:
General -> Editors -> Text Editors -> Annotations
Look for Occurences from the Annotation types list.
Then, be sure that Text as highlighted is selected, then choose the desired color.
And, a picture is worth a thousand words...
(source: coobird.net)
(source: coobird.net)
For those working in Titanium Studio, the item is a little different: It's under the "Titanium Studio" Themes tab.
The color to change is the "Selection" one in the top right.
1 - right click the highlight whose color you want to change
2 - select "Properties" in the popup menu
3 - choose the new color (as coobird suggested)
This solution is easy because you dont have to search for the highlight by its name ("Ocurrence" or "Write Ocurrence" etc), just right click and the appropriate window is shown.
If you're using eclipse with PHP package and want to change highlighted colour then there is slight difference to above answer.
Right click on highlighted word
Select 'Preferences'
Go to General > Editors > Text Editors > Annotations. Now look for "PHP elements 'read' occurrences" and "PHP elements 'write' occurrences". You can select your desired colour there.
right click the highlight whose color you want to change
select "Preference"
->General->Editors->Text Editors->Annotations->Occurrences->Text as Hightlited->color.
Select "Preference ->java->Editor->Restore Defaults
in my case (Eclipse IDE 2021-06), dark theme, the issue was with the background color of "C/C++ Write Occurrences".
On each click over a variable being written in the code, the editor highlights all occurrences of that variable.
You can find this setting here:
General -> Editors -> Text Editors -> Annotations
and then select 'C/C++ Write Occurrences'.
And finally change che Color property.
When auto-completing a class name in Eclipse, e.g. if you type:
ListITab
A pop-up menu appears offering you matching class names for completion (which you can select with the mouse or by using the arrow keys:
In this example, I almost certainly want java.util.ListIterator and I almost never want com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator (or anything else from that package).
This particular class will appear in the list frequently (every time I declare a ListIterator). I would like to be able to exclude packages from autocomplete searches, so that java.util.ListIterator is auto-completed without the need for a pop-up menu.
Is this possible?
Window > Preferences > Java > Appearance > Type Filters
You should be able to specify there the packages you do not want to see.
See Java Tips and Tricks
To exclude certain types from appearing in content assist, use the type filter feature configured on the Java > Appearance > Type Filters preference page.
Types matching one of these filter patterns will not appear in the Open Type dialog and will not be available to content assist, quick fix and organize imports.
These filter patterns do not affect the Package Explorer and Hierarchy views.
finnw (the OP) adds in the comments:
Now how do you add a single class to this list? I'm not interested in java.awt.List but occasionally I want java.awt.Window or java.awt.Dimension. –
"Type filter" is actually based on class pattern matching, meaning if you add:
java.awt.List
that class will disappear from the content assist propositions.
If you know all java.awt.Lxxx classes are of no interest, you could add
java.awt.L*
All other classes from java.awt would still be there for the content assist.
With a recent eclipse (I have right now a eclipse 3.6Mx, but this should work for 3.5.x as well), you are not limited to package pattern only in the Type Filter.
Window > Preferences > Java > Appearance > Type Filters
When auto-completing a class name in Eclipse, e.g. if you type:
ListITab
A pop-up menu appears offering you matching class names for completion (which you can select with the mouse or by using the arrow keys:
In this example, I almost certainly want java.util.ListIterator and I almost never want com.sun.xml.internal.bind.v2.runtime.reflect.ListIterator (or anything else from that package).
This particular class will appear in the list frequently (every time I declare a ListIterator). I would like to be able to exclude packages from autocomplete searches, so that java.util.ListIterator is auto-completed without the need for a pop-up menu.
Is this possible?
Window > Preferences > Java > Appearance > Type Filters
You should be able to specify there the packages you do not want to see.
See Java Tips and Tricks
To exclude certain types from appearing in content assist, use the type filter feature configured on the Java > Appearance > Type Filters preference page.
Types matching one of these filter patterns will not appear in the Open Type dialog and will not be available to content assist, quick fix and organize imports.
These filter patterns do not affect the Package Explorer and Hierarchy views.
finnw (the OP) adds in the comments:
Now how do you add a single class to this list? I'm not interested in java.awt.List but occasionally I want java.awt.Window or java.awt.Dimension. –
"Type filter" is actually based on class pattern matching, meaning if you add:
java.awt.List
that class will disappear from the content assist propositions.
If you know all java.awt.Lxxx classes are of no interest, you could add
java.awt.L*
All other classes from java.awt would still be there for the content assist.
With a recent eclipse (I have right now a eclipse 3.6Mx, but this should work for 3.5.x as well), you are not limited to package pattern only in the Type Filter.
Window > Preferences > Java > Appearance > Type Filters