What is the principle by which keyboard shortcuts selected in IntelliJ IDEA? - intellij-idea

There are lots of useful functions of Intellij IDEA and for many of them there are keyboard shortcuts.
But remembering shortcuts may be difficult, at least for me.
Are there some consistent guiding principles by which these shortcuts were selected by designers? I believe learning such principles would be helpful to memorize shortcuts itself.

I think that the closest answer you're going to get is "it depends". Some shortcuts are obviously chosen, because the keybinding describes what the shortcut does, for example ⌘+O means open, not only in IntelliJ but in many places throughout OS X.
Some shortcuts probably don't have any kind of such semantic meaning, such as Alt+Enter and are chosen because they are very frequently used and the placement of the keys relative to each other is comfortable.
Other keyboard shortcuts with similar purpose have the same starting sequence of keys. For instance the extract refactoring shortcuts, which are as follows:
⌘+Alt+M - extract method
⌘+Alt+C - extract constant
⌘+Alt+V - extract variable
⌘+Alt+F - extract field
⌘+Alt+P - extract parameter
So in such case you only need to remember that if you want to extract something, you press ⌘+Alt and the first letter of what you want to extract.
That being said, I don't believe that the way to learning the keybindings is memorizing them, but using them. If you use one keybinding multiple times, over the time you will memorize it. You can help this process for instance by locating the action you want to perform in the menu, but instead of clicking it look at the keyboard shortcut next to it and press it. Or find the action using ⌘+Shift+A, look at the shortcut and use it.
There are even plugins, which can help you with this, for instance Key Promoter which you can install via Settings/Plugins/Browse Repositories. This plugin shows you shortcut you can use when you invoke some actions by clicking it in menu, etc. It also shows you how many times you've used this action in such a way instead of using the corresponding shortcut.

Related

Is there a way to make IDEs (IntelliJ, PyCharm, VS Code) have fewer popups but still have completion?

I learned to program 30 years ago with Emacs. I'm starting to learn moderns IDEs such as "IntelliJ IDEA", "PyCharm", and "VS Code".
It's hard to adjust to how visually "busy" they are, with constant pop-up menus appearing every character I type.
Of course I want to be able to get suggestions for completion or parameter hints or other popups when necessary. I just don't want them to appear by default.
Some people are asking why popups are annoying. The main problem is that popups cover code above or below where I'm typing.
Emacs has completion. But it doesn't need a popup. For instance, dynamic completion works just fine 90% of the time, even though it's not smart enough to parse syntax or look up function and method definitions.
So I'd like to know if there are settings in JetBrains or VS Code IDE's that would help.
I'm aware of two kinds of popups.
(1) An offer to complete my typing, which appears below.
(2) Annotation of argument names and definitions, which appears above.
There may be other popups as well.
I'm aware that a popup can be dismissed with ESC. But often they just come back the moment you type another character.
What would be great is if the popup would not appear by default, but I could cause it to appear with a single keystroke. Or I could dismiss it and it would stay dismissed.
For PyCharm You can also try writing in "Disctraction Free Mode"
View -> Enter Distraction Free Mode
Which should give you a little screen of calm which will feel a lot more like emacs to you.
It's possible to adjust the behaviour via "Settings".
In IntelliJ IDEA, goto Menu File --> Settings ... , then navigate to Editor --> General --> Code Completion , or type something in the search field (upper left).
Perhaps you find more settings when you browse through Settings dialog.
To be honest, I didn't make a lot of tests with these settings, because I find the helper popups very useful.
Another option to get rid of some "noise" is to adjust settings for displaying parameter names in the code editor.
I switched this off completely.
Go to Settings --> Editor --> General --> Appearance
The new IDEs are really busy looking for libraries, checking/auto closing balanced parentheses, indenting, surrounding methods/functions/procedures/classes as you type. Sometimes I feel the same, but these IDEs are not plain text editors anymore. Every key stroke triggers something which can be time consuming. When the project gets larger and when it has lots of libraries, it can get even slower. Some IDEs have options to turn some of these options off. Every feature turned off will have some positive effect on responsiveness to some degree
But I think, instead of turning these features off, the best way to have these features on a responsive modern IDE is to use a computer with a fast cpu, an ssd drive and sufficient memory.

Use HJKL in menus of JetBrains IDEs

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".

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.

Turn off Intellij signature popup

In IntelliJ 12, how do I make the popup stop...popping up when I hold Ctrl while hovering over a field/method with the mouse? (see picture)
That is the "Brief Info" action (or at least that is what it is called in the Keymap reference.) To the best of my knowledge (i.e. 10+ years of daily IDEA use including all beta/EAP builds), there is no way to turn it off. Searching the settings for either "Brief Info" or "Info" does not show any pertinent setting. Likewise, searching key mappings for the same does not reveal a mapping. In fact in the keymap settings, you can only map mouse clicks, not mouse pointing (i.e. hovering). You can submit a feature request asking for a setting to disable this feature.
Just put of curiosity, why do you want to disable it? I guess I would never see a case where one would Ctrl+MousePoint unless they wanted to see this. The only case I can think of would be if you disliked it popping up when you go to Ctrl+Click on a symbol. If it is the latter, note that you can use Ctrl+B in place of Ctrl+MousePoint
Try turning off the "autopop" options under /Settings/IDE Settings/Editor/Code Completion.

Keyboard shortcut to Un/Comment out code in Mathematica 7?

A keyboard shortcut to comment/uncomment out a piece of code is common in other programming IDE's for languages like Java, .Net. I find it a very useful technique when experimenting through trial and error to temporarily comment out and uncomment lines, words and parts of the code to find out what is and isn't working.
I cannot find any such keyboard shortcut on the Mathematica front end in version 7. I know that it is possible to comment out code by selecting the code, right mouse click and select Un/Comment from the menu that appears but this is too slow while coding.
I tried to access this using the menu key Menu on the keyboard but Mathematica frontend doesn't respond to or recognise this key unlike other applications, this could have allowed a key combination for commenting. Can someone else verify that this isn't unique to my machine and that the key isn't recognised by mathematica. I looked at this question and looked in the KeyEventTranslations.tr file but I don't think there is any way to create a shortcut to do this(?). Should I just live with it?
Any other suggestions?
(I have seen there is an Emacs version of mathematica, I have never tried Emacs or this Mma version and imagine that it would have this ability but would prefer not to go to the trouble and uncertainty of installing it. Also I would guess that the Wolfram Workbench could do this, but that may not be worth the investment just for this.)
You can install the shortcut in Mathematica 7.0.x if you are willing to edit the Mathematica system file MenuSetup.tr. You can find it in the same location as the KeyEventTranslations.tr file (i.e. in the installation under "SystemFiles/FrontEnd/TextResources/platform"). In MenuSetup.tr, locate the following line under the definition of the Edit menu:
MenuItem["Check &Balance", "Balance", MenuKey["B", Modifiers->{"Control", "Shift"}]],
Immediately below that line, insert the following:
MenuItem["Un/C&omment Selection", KernelExecute[FE`toggleComment[]], MenuKey["/", Modifiers->{"Command"}], MenuEvaluator -> Automatic, Method -> "Queued"],
The Un/Comment Selection command is now available under the Edit menu, with the keyboard shortcut Cmd-/ or Alt-/ depending on your platform -- just like in Mathematica 8 where this command comes pre-installed.
Please take as read the usual disclaimers about hacking the Mathematica installation files -- no warranty is offered :)
I do not know of any way to map this function to some shortcut involving the Menu key.
Shortcut Key, No Menu
The preceding steps mimic what Mathematica 8 does by installing a new menu item. If you prefer to leave the menus unchanged, then you can install the shortcut in KeyEventTranslations.tr instead. Add the following line:
Item[KeyEvent["/", Modifiers->{Command}], KernelExecute[ToExpression["FE`toggleComment[]"]], MenuEvaluator -> Automatic, Method -> "Queued"]
You'll need a comma on the end of that line if it is not the last item in the list.
Select the code and press one of the following:
Alt+/
Alt-E-O
Alt+E+O
Notes:
Tested only on Windows, using Mathematica 8.
On my non-US keyboard (ABNT Brazil), the shortcut Alt+/ doesn't work, instead I use Alt+E+O.
Here is code for your KeyEventTranslations.tr file that will comment out code. I am still working on the other half.
Item[KeyEvent["/", Modifiers -> {Command}],
FrontEndExecute[{
NotebookApply[FrontEnd`InputNotebook[],
"(*\[SelectionPlaceholder]*)"
]
}]
],
This binds it to Alt+/ as it is in Mathematica 8.