Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cycle through autocomplete suggestions without arrows

I'm really impressed with the autocomplete feature of the IntelliJ IDE so far.

What I'd like to do, is cycle through the autocomplete suggestions I get when hitting Ctrl + Space without using the arrow keys (, ).

The reason for this is that I prefer to keep my fingers on the home row (I'm using IntelliJ's Vim emulator additionally).

For example, how would I select sortThis instead of sorted without using the arrow keys or the mouse?

autocompletion example

like image 916
Matthias Braun Avatar asked Oct 12 '14 09:10

Matthias Braun


4 Answers

Peter Gromov's answer brought me to a satisfying solution:

In IntelliJ's settings, for Keymap → Editor Actions → Down I set a custom shortcut: Ctrl + J.

This way I can cycle forward through the suggestions.

down_shortcut

Setting a shortcut for Down with Selection or Scroll Line Down in the IdeaVim-specific shortcuts did not affect the selection of autocomplete suggestions though.

like image 164
Matthias Braun Avatar answered Nov 10 '22 11:11

Matthias Braun


For macOS the IDE will give a hint that "^↑ and ^↓ will move caret up and down in the editor". These clearly do not work.

There are a few extra steps that are needed after following @matthias-braun's solution.

Here is the full list of step that I use:

  1. Go to Preferences -> Keymap
  2. Expand Editor Actions (not Plug-ins -> IdeaVim)
  3. Select Down
  4. Click the pencil icon or right-click
  5. Select Add Keyboard Shortcut
  6. Press the shortcut (I use ^N)*
  7. Repeat for 3-6 for Up (I use ^P)
  8. Click Ok**
  9. Go to Preferences -> Other Settings -> Vim Emulation
  10. In the drop-down under the Handler column for the row containing Down, select Vim***
  11. Do the same thing for Up

* If you are warned about the key binding already existing then remove it. You can always reset back to the defaults by clicking the little cog icon up the very top to the right of the drop-down menu.

** The Vim Emulation doesn't seem to be populated correctly until you reopen the Preferences.

*** I'm not sure why the Handler should be Vim. This seems backwards to me but it works.

like image 20
steinybot Avatar answered Nov 10 '22 12:11

steinybot


The answer here: https://stackoverflow.com/a/9713306/2370679 led me to discover that Ctrl+n & Ctrl+p allow navigation of the auto-complete options without having to modify any settings

like image 7
muya_ Avatar answered Nov 10 '22 12:11

muya_


If you're able to scroll up/down in editor with some IdeaVIM-specific shortcuts, they should also work in the completion list.

In this particular case, I'd just type another "t" so that "sortThis" becomes selected (and the only) variant.

like image 2
Peter Gromov Avatar answered Nov 10 '22 10:11

Peter Gromov