After installing the most recent update to STS 3.9.0, my Ctrl+Shift+O keyboard to Organize Imports is no longer working. The key shortcut exists in Preferences->General->Keys ("Keys" preferences) but is missing in the Source menu ("Source" menu).
Instead of resolving each unresolved references, you can press CTRL+SHIFT+O that is a short cut for organize imports in Spring STS or any eclipse based tool. If you are working on Mac like me then the shortcut is COMMAND+SHIFT+O.
The main preference page can be found under Window > Preferences > General > Keys (or faster: Press Ctrl+3, type Keys and press Enter). From here you can see all commands and assign/change their associated keyboard shortcuts.
Automatically organise import statements whenever you save Here are the steps to organising imports whenever you save: Go to Window > Preferences > Java > Editor > Save Actions. Select Perform the selected actions on save (off by default). Ensure that Organize imports is selected (on by default).
In Eclipse, you press CTRL + SHIFT + O “Organize Imports” to import packages automatically. For IntelliJ IDEA, if you press CTRL + ALT + O “Optimize Imports”, it just removes some unused imports, never imports any package.
This is a bug. You can workaround it by fixing the Eclipse shortcut keys preferences.
From the bug report:
here is how you can fix that issue:
Go to the Preferences -> General -> Keys press Filters... and de-select Filter uncategorized commands. Look for the command "Go To Symbol in File" and select that, press unbind and Apply and Close
Another way to fix this that survives STS restarts is to go: Preferences -> General -> Keys and change the "When" value to 'Editing Java Source'.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With