Keeping Code Collapsed - Eclipse IDE - java

Just curious if there's a setting somewhere in Eclipse to keep blocks of code collapsed when the class is opened? It's just I'll collapse methods then when the class is re-opened, everything is expanded.
Thanks

In Windows > preferences:
Java > editor > folding: check all, click apply & then OK.
Maybe this helps: Ctrl + Shift+ NUM_KEYPAD_DIVIDE collapse all methods in a java class.
Source

Yes . From the eclipse official documentation :
You can specify which regions are folded by default when an editor is
opened. Have a look at the Opens the folding preference page Java >Editor > Folding
preference page to customize this.
Just click all the checkboxs .Then whenever a .java file is open in the java editor , everything will be collapsed.
Not sure if this options is the new feature for eclipse indigo version (3.7) , so you may have to update your eclipse to indigo if you use older version but cannot find this option.

I'm not aware of a solution, but let me tell you how I work - maybe this is a solution for you as well:
Enable "Only show the selected Java element". The editor will only show the element (method) you selected (see screenshot).
While editing a file use either the Outline view or CTRL + O to navigate through the class file.
Btw: I disabled all folding options as the above approach just works best for me. Sadly, I'm not aware of a shortcut to enable/disable the "Only show the selected Java element".

Yes, you can set the options what to fold on file open.
You can find it at Settings->Editor->Folding
It features a resonable selection of folding options.

Related

Eclipse Organize Imports Shortcut (Ctrl+Shift+O) is not working

Eclipse used to import missing packages when I press Ctrl+Shift+O.
The shortcut key has stopped working when used in Java files but the same shortcut is working in Python files (importing missing packages).
Any thoughts on how to fix the issue.
Below are couple of snapshots for your reference.
The Java Organize Import command is overwritten by another Ctrl+Shift+O command: in Window > Preferences: General > Keys the Java Organize Import command (where When is In Windows) is bound to Ctrl+Shift+O, but in the main and right-click menu Source > Organize Imports the command is displayed without the shortcut.
There are two solutions for this problem:
Change or remove the shortcut of the command that overwrites the Java Organize Import command:
Find the command: In the Java editor press Ctrl+Shift+L and see which command is bound to Ctrl+Shift+O. Probably, it is the Beans Quick Outline command.
In Window > Preferences: General > Keys change or remove the binding for the found command.
Restricts the scope of the shortcut of Java Organize Import to the Java editor:
In Window > Preferences: General > Keys select the Java Organize Import command and change When from In Windows to Editing Java Source. This solution restricts Ctrl+Shift+O to the Java editor and disables the shortcut in the Package/Project Explorer.
See also: Spring IDE issue #160: organize imports is not working
To fix this issue:
Go to Preferences -> General -> Keys
Click on Filters... and de-select Filter uncategorized commands then Ok.
Then look for the command Go To Symbol in File and select it.
Then click on Unbind and then Apply and Close
Ctrl+Shift+O. should now work.
EDIT:
Also unbind any other conflicting commands and leave only one command for Ctrl+Shift+O and set the When to Editing Java Source.
Please keep in mind that if you are using an AMD GPU, your Radeon Driver could block Ctrl+Shift+O which is used to toggle an ingame-overlay. It can be changed to other keys as follows: Games → global settings → performance monitoring
Window -> Preferences -> General -> Keys
Click on Binding to sort by Binding then scroll and find Ctrl+Shift+O
If several Organized imports are present edit one bind and choose WHEN: EDITING JAVA SOURCE.
Remove( UNBIND COMMAND) for other existing bindings.
Restart Eclipse
Above shortcut resulted in GPU details being popped up on my screen. SO it was bound to some other app which was overriding it. What worked for me is
-> check.
You need to go to Gaming > Global Settings > Performance Monitoring > Toggle Performance Logging Hotkey
You will see this is bound to Ctrl + Shift + O (so the shortcut is used - just buried).
To remove the shortcut (not an obvious process at all!) you need to click the Toggle Performance Logging Hotkey button, it will then ask to enter your hotkey, you then press delete - that is Del (not backspace, not esc or anything else - the Del key).
i did all but not worked so i checked the AMD forum (https://community.amd.com/thread/227221) and found out my solution which is;
"Now I find that all I need to do is to go to Radeon Settings -> Preferences and uncheck the Show Overlay box."

How to fix Eclipse autocomplete not working

The autocomplete of eclipse is not working now and I searched for hours but I couldn't find an answer to solve it. I haven't used it for long time then the first thing after opening it was to install SWT and windows builder even though I had swing installed. What I mean is, it is may possibly be because of some conflict caused by swt and swing(I read something about a conflict but I don't if this is possible).
Strange thing is it doesn't show anything when I press ctrl+space but when I go Edit-> Content Assist -> Default(it says Ctrl+Space nearby it), it shows things needed to be shown/works as desired.
public class Dsada {
String sssss;
public Dsada(){
sss //pressing ctrl+space is not working,Edit->ContentAssist->Default works fine
}
}
The solution is not to tick/untick some stuff under Windows->Preferences->...->Content Assist-> Advanced. I checked if "ctrl+space" is hijacked by some other thing which is not and checked keyboard language which is English(Those are suggested in mkyong).
I read something about a bug but I couldn't understand. I tried to delete eclipse and re-install again but I guess some settings just stayed in the machine so that it didn't work.
This is recurring for me. I'm using Eclipse 2019-03 in Windows 10.
The steps below work for my case, and does not require a restart.
Window->Preferences->Java->Editor->Content Assist->Advanced
The following options are de-selected, and when I set them the autocomplete worked as before. No restart needed.
1. Java Non-Type Proposals
2. Java Proposals
3. Java Type Proposals
4. Java Proposals (Task-focused)
I don't know what's triggering this but it only happens after I've created a new project. Usually doesn't. It simply doesn't happen often enough for me to notice a pattern to follow up on more.
Clearly this problem occurs with a variety of causes, so review the other answers to see if they match your case.
The hot key combination ctrl+space might be conflict with other settings in system if you are using windows.
Try modify this combination like alt+/, i always use this one since the first time i knew eclipse. It works well.
Hope it works for you.
Window->Preferences->Java->Editor->Content Assist->Advanced
The following options have to be selected, then the autocomplete worked . No restart is required.
Java Proposals (must be selected, not sure the follows)
Java Non-Type Proposals
Java Type Proposals
Java Proposals (Task-focused)
I was facing the same issue. If you use OS X Eclipse Ctrl+Space shortcut can be interfering with OS X system's "Selecting previous input source" using Ctrl+Space shortcut as default.
It is necessary to
edit System Preferencies/Keyboard/Shortcuts/Input Source and uncheck the "Selecting previous input source" or change the shortcut on something else. Eclipse should work after that even without restart.
I faced hot key problem with use Ctrl+Space. I tried to fix the issue first by Windows->Preferences->...->Content Assist-> Advanced and selected
Select the proposal kinds contained in the 'default' content assist list:
Other Java Proposals,
List item
SWT Template Proposals
Template Proposals
Type Proposals
but didn't help.
Therefore, I tried another solution. There would be multiple languages on your computer which could be eating up your Ctrl command. To solve this Go to Control Panel -> Region and Language -> Keyboards and Languages (tab) and then Change Keyboards.
You’ll see a list of languages installed – remove any that you don’t want (click the language and then click the Remove button) until you only have the ones you want left. That fixed it for me, but you can also check the Advanced Key Settings tab to make sure that none of the keyboard short-cuts that are set include Ctrl-Space.
Once you’ve done that, Ctrl-Space should work nicely!!!!
I had the same Problem on Ubuntu 14.04. The problem for me was that ibus used Ctrl+Space as a shortcut. I solved it by starting the program ibus-setup and chaning the shortcut to something else than Ctrl+Space.
Go to Windows >> Preferences » Java » Editor » Content Assist. Then Check the Auto activation triggers for java, Add this in the text box .abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ
Recently, I also faced this issue. When I install neon version eclipse.
By (1) deleting respective class, (2) restoring defaults appearance and (3) restarting eclipse, solved the problem for me.
Hope it will help someone.
Go to Preferences » Java » Editor » Content Assist » Advanced. Make sure Other Java Proposals is ticked/checked.
I checked windows has no conflict of ctrl+space (of eclipse autosuggestion) with windows.
This is mere configuration issue of eclipse. reinstallation would fix it.
Thanks.
I select all the parameters in Preferences -> Java -> Editor -> Content Assist -> Advanced.
It help me and resolve the my problem.
Cltr+space work using this step.
Saving my work and restarting Eclipse solved this for me. I hadn't shut down Eclipse in a while, maybe weeks.
I had the same problem (MacOS Monterey, Eclipse 06-2022). Turned out it works with pressed fn button.
For Mac user, you can try : Preferences -> Java > Editor > Content Assist and then :
tick the field "Enable auto activation"
in the field Auto activation trigger for Java, you can input the text alphabet ".abcdefghijklmnopqrstuvwxyz"

No syntax highlighting in eclipse for java

There is no syntax highlighting in java files in my eclipse..This happened all of a sudden..Not sure why..
This is how it is looking now..
As mentioned in other posts..i tried to change the color from preferences window and there is nothing when i type java..something really messed up...
AAny suggestions..
Update:
It seems Java plugin is not installed..as per the below screeenshot
And when i try to install java plugin it says new version is already installed as per the below screenshot
Closing the file's tab and re-opening it fixed it for me.
(I actually closed all the tabs...)
I faced the same issue all of a sudden after a commit/update project operation.
The point is, default editor of Eclipse has changed somehow and we have to set it back to normal.
Try the below method,
1. Goto Windows -> Click Preferences
2. From the Preferences window goto General -> Editors -> Click File Associations
3. You can choose the default editor for *.java files here
When I first opened Preferences, 'Text editor' was set as the default editor for .java files and then I changed it back to 'Java Editor'.
Now it works perfectly fine.
You probably have a corrupt installation or you have recently installed a corrupt plugin.
The following steps might help.
In your Install window,
view your "already installed" plugins.
select the "Installation History" tab.
select a previous stable configuration
Click the "Revert" button
TLDR; open another workspace, then come back to the original workspace.
Ok this is odd, but for me, all the highlighting suddenly went away for Java files. I explored all of these ideas here, with no effect. I created a new workspace, planning to move everything to it. I realized that can be a pain to move many projects over, so I went back into the original workspace to look at some settings, and poof - the highlighting was working again.
I have one java class file like a text editor.
I tried following,
Select the respective java class file from eclipse.
Right click on the file and mouse hover on "Open with".
Select java editor.
Now its works.

How to see JavaDoc in IntelliJ IDEA? [duplicate]

This question already has answers here:
IntelliJ show JavaDocs tooltip on mouse over
(21 answers)
Closed 5 years ago.
I just switched from Eclipse to IntelliJ. IntelliJ lacks one feature from Eclipse - when you put your mouse over a method, Eclipse shows javadoc info. I think the way to show it is to use a shortcut - command+J, but when I click it, I get something wrong as on the screen shot below. Please advise me on how I can quickly get javadoc information. I need to at least know what type a method returns.
Use View | Quick Documentation or the corresponding keyboard shortcut (by default: Ctrl+Q on Windows/Linux and Ctrl+J on macOS or F1 in the recent IDE versions). See the documentation for more information.
It's also possible to enable automatic JavaDoc popup on explicit (invoked by a shortcut) code completion in Settings | Editor | General | Code completion (Autopopup documentation):
Yet another way to see the quick doc is on mouse move:
Alternatively you can position your cursor on the item and show JavaDoc using
CTRL+Q
which is the default shortcut.
Edit: As Methical mentioned on Mac the shortcut is
CTRL+j (^+j not ⌘+j)
Go to File/Settings, Editor, click on General.
Scroll down, then ✔ Show quick documentation on mouse move.
There is nice feature which shows quick documentation when your mouse is over element.
IntelliJ 14
Editor / General -> Show quick documentation on mouse move
Older versions
Add the following line to idea.properties file:
auto.show.quick.doc=true
Configuration for IntelliJ IDEA CE 2016.3.4 to enable JavaDocs on mouse hover. I am running IntelliJ IDEA on Mac OS but believe that Linux/Windows should have similar options.
Autopopup docs:
IntelliJ IDEA > Preferences > Editor > General > Code Completion
Documentation on mouse move:
IntelliJ IDEA > Preferences > Editor > General
NOTE: Please hit Apply button to apply these settings
To best mirror Eclipses functionality, enable the following settings:
IDE Settings/Editor -> Other.Show quick doc on mouse move
IDE Settings/Editor/Code Completion -> Autopopup Documentation
To see the javadoc in the autocomplete menu, hit '.' to get the popup, then hover over the object you are working with, once you get the javadoc popup, you can select an item in the popup to switch the javadoc over. Not ideal... But its something.
As another note. The search functionality of the options menu is very useful. Just type in 'doc' and you will see all the options for doc.
Also, searching for "autopopup doc" will not only find each of the options, but it will also highlight them in the menu. Pretty awesome!
Edit:
Going beyond the initial question, this might be useful for people who just want quick and easy access to the docs.
After using this for a few more days, it seems just getting used to using the hotkey is the most efficient way. It will pop up the documentation for anything at the spot of where your text input marker is so you never have to touch the mouse. This works in the intellisense popup as well and will stay up while navigating up and down.
Personally, Ctrl+Q on windows was not ideal so I remapped it to Alt+D. Remaping can be done under IDE Settings/Keymap. Once in the keymap menu, just search for Quick Documentation.
For me, it wasn't just getting the javadoc window to open, but also getting the complete javadoc to present. You may still get a sparse javadoc that is based solely on the method signature if you are importing libraries from a Maven repository and do not tell Idea to include the javadocs in the download. Be sure to tick the "JavaDocs" option in the "Download Library From Maven Repository" dialog, which can be found under Project Structure -> Projtect Settings -> Libraries.
Go to Settings -> Editor -> General then enable Show quick documentation on mouse move
IntelliJ IDEA 15 added this feature
Now it is available as EAP.
As you can see in the picture below, the caret position doesn't influence the cursor position:
This feature was implemented in IntelliJ IDEA 15 142.4675.3 Release Notes.
The closest to Eclipse will be Ctrl+Button2 Click (Scroll click)
It's called Quick Doc in IntelliJ, I wish guys from JetBrains one day add quick doc like Eclipse with Ctrl+Mouse Move it's so much better.
In my case only with only mouse move is a bit annoying, so if you search in Preferences/Settings --> Keymap for "quick documentation" you will find:
Win-Linux: "Ctrl+Q" and "Ctrl+Button2 Click" (Scroll click)
Mac: "Ctrl+J" and "Ctrl+Button2 Click" (Scroll click)
I have noticed that selecting the method name and pressing F2(Quick Documentation) dispalys it's JavaDoc.
I am using Intellij 2016, and Eclipse Keymap

Eclipse does not highlight matching variables

Eclipse does not highlight matching variables for me:
I've already tried to change "Mark occurrences" via
Window -> Preferences -> Java -> Editor -> Mark Occurrences
but it didn't work. I am not sure why this is not working while others
have been able to fix the problem.
Can anyone tell me how can I set highlighting matching variables?
Looking for same variables with my eyes really bothering me too much.
Try:
window > preferences > java > editor > mark occurrences
Select all options available there.
Also go to:
Preferences > General > Editors > Text Editors > Annotations
Compare the settings for 'Occurrences' and 'Write Occurrences'
Make sure that you don't have the 'Text as higlighted' option checked for one of them.
This should fix it.
Alt + Shift + o
Will solve your problem and agree with #Korhan Ozturk as well :)
This is known as Toggle Mark occurrence (Alt + Shift + O), Means will highlight all occurrence of focused variable.
Same thing can be achieved from tool bar as follows
In same tool bar there is another switch if you turn that on you will see complete path for opened file, That is Breadcrumb
there are some more very useful switches like word wrap, Show white Characters just after toggle mark occurrence
There is a bug in Eclipse Juno (and probably others) but I have a workaround!
If you have already checked all the configurations mentioned in the top answers here and it's STILL not working try this.
To confirm the problem:
Select a variable
Notice the highlight didn't work
Click away from eclipse so the editor loses focus.
Click on eclipse's title bar so it regains focus, your variable should be highlighted.
If this is happening for you, you must close ALL of your open files and reopen them. This bug seems to also make weird things happen with Ctrl+S saving of an individual file. My guess is that something is happening whereby internally eclipse believes a certain file has focus but it actually doesn't, and the UI's state is rendered as though a different file is being edited.
Edit: If it's STILL not working, you might need to restart eclipse, but if you don't want to, try selecting the item you want to see occurrences of then disable and re-enable the Mark Occurences Toggle button.
The only that worked for me was:
Java > Editor > Mark Occurrences:
Check "Mark occurrences of te selected element in the current file."
... and maybe all the ones below.
Using Alt + Shift + o
It works for me!
For others running into this without any of the above solutions working AND you have modified the default theme, you might want to check the highlight color for occurrences.
Preferences > General > Editors > Text Editors > Annotations
Then select Occurrences in the Annotation Types, and change the Color Box to something other than your background color in your editor. You can also change the Highlight to a outline box by Checking "Text as" and selecting "Box" from the drop-down box (which is easier to see various syntax colors then with the highlights)
I wish I could have read the response by #Ján Lazár.
In addition to all the configurations mentioned in the accepted answer, below setting solved my misery:
For large files the scalability mode must be turned off. Enabling scalability mode will disable reference highlighting.
PS: #Rob Hruska It would be great if this point is added in the accepted answer. Most of the readers do not bother to read the last response.
For PHP you can set
window > preferences > PHP > editor > mark occurrences
Please check first checkbox (Mark occurrences of selected element in the current file)
And also check
Preferences > General > Editors > Text Editors > Annotations
'Occurrences' and 'Write Occurrences' with different style and color
If highlighting is not working for large files, scalability mode has to be off.
Properties / (c/c++) / Editor / Scalability
.
Java - Editor - Mark Occurrences
Eclipse Java EE IDE for Web Developers.
Version: Photon Release (4.8.0)
maybe because it not supports code highlights inside scriplets. not sure though.
You can try using one of the eclipse plugin like 'glance search' which works great.
Here's a link for that-
http://code.google.com/p/eclipse-glance/
I just unchecked all, applied, checked all again, applied and it worked :) hopefully helps others.
Eclipse Toolbar > Windows > Preferences > General (Right side) > Editors (Right side) > Text Editors (Right side) > Annotations (Right side)
For Occurrences and Write Occurrences, make sure you DO have the 'Text as highlighted' option checked for all of them. See screenshot below:
I was having the same issue and the "make occurrences" and "annotations" solutions above did not help. If you are using Maven, I had to convert the project to a Maven project (right click on it in the Package Explorer and go down to configure), then build the project. Then the syntax coloring and highlighting worked correctly.
This is what worked for me (credit to YardenST from another thread):
Instead of double clicking file when opening, right click on file -> Open with -> Java editor
In Scala IDE click on this button in the toolbox to activate Mark Occurrences (off by default).
link to the screenshot
Sometimes problems in your project build path can cause this, make sure you resolve it first, in my case the prolem was :
And when fix it highlights come back.
I had this issue with Eclipse Mars for PHP developers, 64 bit edition for Windows. I now discovered that highlighting works out-of-the-box with the 32 bit version. Even with a fresh download of the equivalent 64 bit build, highlighting does not work. So I will switch back to 32 bit (this is actually not the first problem I observe with Eclipse 64 bit).
Edit:
I thought this was the solution, so I installed the 32 bit version in C:\Program Files (x86) and set a shortcut in the "Start" menu. When I started Eclipse from there, highlighting again ceased to work. I now got it working again by deleting the .metadata directory in the workspace (i.e. resetting the workspace settings) and re-importing the projects.

Categories

Resources