Use HJKL in menus of JetBrains IDEs - intellij-idea

Is it possible to use J and K when choosing a suggested auto-completion item? See the image below: I'd like to, maybe hold ALT or SHIFT (or in some other way differentiate between moving and typing), and use J and K to select the proper suggestion.
Is anything similar also available for moving around the menus (in Project view etc.)?

I was able to make this work by creating a shortcut ALT+J mapped to the Down key and ALT+K to the Up key.
You can move up and down in the popup without needing to move your hand away from HJKL to the arrow keys.
This also works in the Find in path window, though it does not work in the navigation menu.
Update: For Alt + K to work in the Find window since the version 2020+, one has to disable mnemonics in Settings, under Appearance & Behaviour -> Appearance -> Disable mnemonics in controls.

#Rok Povsic's solution is great and I used it a bit, but in some pop up menus like Intention actions, refactoring menu or usages the trick won't work.
So I used this Power Toys program from Microsoft to remap the Alt+J, Alt+K, Alt+H, Alt+L to arrow keys at windows level and now this works great everywhere around the IDE.
You can even specify only the app in which you want to override this shortcuts. For example for rider it will be "rider64.exe". You can find the name of the app you want to use in task manager under "Details".

Related

How to expand menu in IntelliJ without using right arrow

I am currently using IDEAVim on intelliJ on a 60% keyboard without arrow keys.
I am looking for a way to expand the menu of "Show Intentions Action"(the menu which you get from hitting + ) to the right without having to use the arrow key.
If i just hit enter, it will select and execute the intention instead of giving me a menu to "Suppress" or "Ignore" the intention
You cannot remap any cursor keys for the menu actions in IntelliJ IDEA.
The only workaround I can see if to use some system application to remap the keys depending on the OS you are using. For example, on Windows one can map some keys combination to produce the arrow key code with AutoHotkey or a macro in the third-party keyboard driver settings.
Anything that will produce the same code as the real right arrow key on your system should work.

IdeaVim: How to cycle through list items without using arrow keys?

Is there a way to move through list of suggestions without leaving keyboard home row? I am looking for some kind of vim-style analog to up/down arrow actions.
For people reading this on 2019
you can use Ctrl + n and Ctrl+ p to cycle the autocomplete options
Reference: https://youtrack.jetbrains.com/issue/VIM-438#comment=27-520874
You can bind Fn + hjkl to arrow keys globally in your OS. No more leaving the home row, ever! Fn is often located in the bottom left corner of the keyboard where you can easily reach it with your left palm.
On OS X you can remap the keys using excellent Karabiner software (formerly known as KeyRemap4MacBook) which has a "Vi mode" preset.
On Linux there are several solutions using xmodmap or XKB, see https://superuser.com/questions/96299/mapping-superhjkl-to-arrow-keys-under-x. You might need to substitute Fn for LCtrl: I'm not sure if Fn is visible to key remapping code at all.
Not sure if there are any options on Windows.
Also, certain high-end keyboards can remap keys in hardware as well.
On Windows, you can use AutoHotkey to remap Win+jk to DownUp
#j::Send {Down}
#k::Send {Up}
On OS X one can use ⌃+N and ⌃+P. No external tools required!

Use VI keys everywhere instead of cursor keys

I like VIM a lot because it kind of doubles the power of my keyboard in a way. It's either in insert or motion or whatever they call it mode.
Navigating through source code, typing code, while being able to keep my hands in the touch type position is great.
But when a dialog box is opened (eg. the one using ctrl+F12), if I have to select something other than the first one in the list, I am forced to have to move my right hand to the cursor keys.
Is there a way so that I can use J and K or else something with ctrl or alt or something, so that I can select an item while keeping my hands in the touch typing position?
You can redefine shortcuts for the Up, Down, Left, Right actions in File | Settings | Keymap (the regular keymap that has nothing to do with IdeaVim). IdeaVim provides Vim emulation only for code editors like file editors, interactive language consoles, etc.
Edit: I guess you can't use j and k since characters typed in the structure window are reserved for searching. But you can use Ctrl+N and Ctrl+P which is the same as the navigation shortcuts for pop-up windows in Vim.
Edit 2: You can't use Ctrl+N and Ctrl+P as well due to this bug in IntelliJ.

IntelliJ-IDEA Eclipse Ctrl+O equivalent that is better than Alt+7

In Eclipse I could hit Ctrl+O and get a popup which I could use to get an overview of everything in the current class, pick an entry, and jump to it.
In idea, there is Alt+7, but I have a few issues with it. First, the keyboard doesn't seem to put its focus there. I have to take my hand off the keyboard and use the mouse to place the focus on the Structure dock.
I also don't like how it's taking up real estate. I don't want to change how things are laid out if I want to see the structure. I would like a more non-invasive popup, and handier and snappier.
Is there another feature that gives me quick access in the form of a popup preferably, like Ctrl+O provides in Eclipse?
Another nice feature would be to be able to use the J and K keys to move up and down the selection, instead of having to use the cursor keys. I'm using IdeaVim, so the normal workflow when editing files, is that both hands stay in a touch-type position. It would be nice if I can use the various navigation features also using vim keys...
Perhaps there is a way to enable this, that I haven't discovered yet?
IntelliJ equivalent of Eclipse's CTRL+O is CTRL+F12 (⌘+F12 on Mac), which will give you more or less the same pop-up as in Eclipse. But I'm not sure if it can be navigated using j and k keys.
More details can be found in the IntelliJ help.

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?
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.
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.
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
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:
Go to Preferences -> Keymap
Expand Editor Actions (not Plug-ins -> IdeaVim)
Select Down
Click the pencil icon or right-click
Select Add Keyboard Shortcut
Press the shortcut (I use ^N)*
Repeat for 3-6 for Up (I use ^P)
Click Ok**
Go to Preferences -> Other Settings -> Vim Emulation
In the drop-down under the Handler column for the row containing Down, select Vim***
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.
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.
I have done the same thing with mapping the arrows but in a more logical way:
I mapped them that when I press 'Alt' 'J' is left, 'L' is right, 'I' is up, and 'k' is down. that way I can have easy access to the arrows while my fingers are on the home row and I don't need to move them nearly as much...
I'm posting it just so people who search it on google can have that idea.