2

I'm using Eclipse (STS version 3.9.0) on macOS Sierra. I have a fresh install of STS. Organize Imports (Cmd + Shift + O) is defined out of the box. I can get this function to work by going through the menu entry Source > Organize Imports, but the key combination does nothing.

Additionally, the shortcut combination is not shown next to the menu item, while other menu items do have shortcut combinations shown.
Missing menu shortcut

What can I do to get this functionality via keystroke?

I have seen this happen on two different machines.

I have checked there are no other conflicting keybindings by sorting by the binding:

Properties | Keys

Paul Waldo
  • 831
  • 7
  • 19
  • Is it assigned in the 'General > Keys' section of the Preferences? This works fine for me on macOS with plain Eclipse Oxygen. – greg-449 Aug 01 '17 at 19:08
  • @greg-449 yes it is – Paul Waldo Aug 01 '17 at 19:09
  • Just guessing but you could check for a clash with a macOS shortcut (look in the macOS System Preferences in the Keyboard section on the Shortcuts tab). – greg-449 Aug 01 '17 at 19:15
  • 1
    Possible duplicate of [Eclipse Organize Imports Shortcut - Ctrl+Shift+o is not working](https://stackoverflow.com/questions/45256038/eclipse-organize-imports-shortcut-ctrlshifto-is-not-working) – Kohei TAMURA Aug 01 '17 at 19:53
  • @greg-449 yes, I suspected that also. I checked and no clashes there either – Paul Waldo Aug 01 '17 at 21:34
  • @KoheiTAMURA thanks for the suggestion. I don't think this is the same. Hopefully my edits will show that. – Paul Waldo Aug 01 '17 at 21:58
  • In _Preferences_, could you filter the keys for `⇧⌘O`? – howlger Aug 01 '17 at 22:55
  • @howlger I did that. Please see screenshot. – Paul Waldo Aug 01 '17 at 23:20
  • Please check my answer. – Kohei TAMURA Aug 02 '17 at 01:55
  • @PaulWaldo The screenshot does not show the filter field above the table. Was it empty? The Java _Organize Imports_ is set to the widest possible scope _When In Windows_ (because it is not only available in the Java Editor but also in the Package/Project Explorer). It will be overridden by every command bound to the same shortcut but with a more specific scope, e. g. _Text Editing_ or _Editing in Structured Text Editors_. To which shortcut is your _Beans Quick Outline_ command bound? For details see [my answer for Linux/Windows](https://stackoverflow.com/a/45266159/6505250). – howlger Aug 02 '17 at 06:21
  • @howlger thanks for that suggestion and pointer. It turns out the comment in your answer by user206079 was the key: "The link provided has helped to resolve the issue. By changing the **when** from **In Windows** to **Editing Java Source**, the shortcut key started to work." Note that unbinding Beans Quick Outline did not work. I can now Organize Imports in a Java file. It seems odd that default key bindings have this broken. – Paul Waldo Aug 02 '17 at 08:03

2 Answers2

8

In Preferences > General > Keys > Filter the keys for ⇧⌘O

By changing the When from In Windows to Editing Java Source, the shortcut key started to work for me.

I've seen the answer on the comments above but it wasn't easy to see, that's why I'm writing it right here for more clarity. Thanks Paul for the question & answer.

GuiFalourd
  • 822
  • 7
  • 16
0

Try the following steps:

  1. Go to Windows -> Preferences-> General -> Keys on STS Menu
  2. Click "Filters..." on the Keys page and uncheck all.
  3. Enter "⇧+⌘+O" to search the command list for ++O.
  4. You can see the command list, and then unbind commands other than "Organize Imports".
  5. Click "Apply".
Kohei TAMURA
  • 4,238
  • 6
  • 20
  • 41