IDEA - Is there any way to make combined(merged) action shortcuts? - intellij-idea

For example, alt + cmd + v is shortcut for behavior split vertically, and alt + cmd + b is shortcut for go to implementation. Question is how do I merge these two actions split vertically and go to implementation into only one shortcut(say cmd + i)?

I managed to do what you need by following these steps;
cmd + shift + a(find in action) + type start macro recording
enter your commands consecutively (shortcuts). It will start recording every shortcut/keystrokes.
cmd + shift + a + type stop macro recording
enter a name for your macro (testmacro)
cmd + shift + a + type edit macros and select your recently created macro (testmacro)
The list should be as following;
Action: SplitVertically
Action: GotoDeclaration
update your macro by pressing ok
select or put your cursor on the variable/method/class that you want to go to the declaration and hit - cmd + shift + a + type testmacro and enter
Alternatively, it could be better to assign a shortcut to Play saved macros and then instead of typing a lot, you can select your macro from the list after hitting the shortcut of play saved macros.
Here are the screenshots of the process

Related

Toggle Comments Keyboard Shortcut (CTRL + /) Does Not Work

I use SAS Enterprise Guide and Teradata Studio Express to code for my day job. WindowsOS.
I use CTRL + / shortcut to comment lines of code out in both apps. Suddenly, this shortcut has stopped working. I've checked all my keyboard and Code Shortcut Key settings in both apps and nothing seems out of place!
All other shortcuts seem to work in both apps, common ones I use like CTRL+C (copy), CTRL+X (cut), CTRL+V (paste) etc
I've got no idea why the 'comment out' shortcut is unable to register. Anyone else encounter this same annoying issue?
CTRL + : will pack your line in /* and */
If you have selected a range, Enterprise Guide will do that with every line from which you selected any character.
CTRL + Shift + : will unpack them
You just have to define it again.
Go to Tools-->options-->Enhanced Editor Keys
Select the Command "Comment the selection...." and press Assign keys
within "Press new shortcut key:" enter the ctrl + : key and press assign

Quickfix for creating field variable - how to get back

Is it possible to get back to my previous caret position after i do a quick fix for create Field on a variable?
test = new String();
My caret is on "test" and i press ALT+ENTER -> create field 'test'
caret goes up to the top of the class and i can edit the Type then i press TAB to get to the name of the variable but after that i only can press ENTER and i don't go back to my line in the code.
I tried ENTER, TAB, ESCAPE.
Refactoring to Field works fine.
Use Intellij shortcut for navigating to last cursor location.
Mac: Alt + Command + Left Arrow
Win: Alt + Control + Left Arrow
Similarly, you can also cycle forward to the last cursor location using
Mac: Alt + Command + Right Arrow
Win: Alt + Control + Right Arrow

Intellij comment shortcut opens help tab on the Mac menu bar

When I use the Cmd + Shift + / keyboard shortcut to comment/uncomment a block of code, the Help tab on the menu bar in IntelliJ also opens.
Does anyone know how to prevent this shortcut from opening the Help menu tab in IntelliJ 16.1.2? I am using the Mac OS X 10.5+ shortcuts.
Remove or replace the Cmd + Shift + / shortcut in your mac. Apple menu-> System Preferences-> Keyboard -> Shortcuts.
Steps:
Remove or replace the Cmd + Shift + / shortcut on your Mac (as mentioned by #Bajal)
Add new Intellij shortcut Cmd + 7 for "Comment with Line Comment" (Preferences -> Keymap)
I used this work around but it didn't fix the problem:
In IntelliJ, I went to Preferences -> Keymap and I searched for comment. It turns out that there are 3 different commands to comment/uncomment a block of code.
Cmd + Shift + /
Ctrl + Shift + /
Cmd + Alt + /
My work around to prevent Cmd + Shift + / from opening the Help menu tab is to use one of the other keyboard shortcuts.
This doesn't answer my question fully so if anyone has any suggestion please let me know as I would prefer to use Cmd + Shift + /
I had the very same issue. The solution by Bajal helped, because the shortcut didn't trigger the help tab. But it didn't allow me to line comment my code.
So I had to add Shift + Cmd + 7 to the keymap. This is exactly the same as Cmd + /, but I had to add it anyway.

Duplicate whole method via keyboard shortcut?

I often use Ctrl + D to copy one line of the code.
Is there a keyboard shortcut in IDEA where I can put a caret on the method name and pressing the shortcut combination duplicate the whole method? Ctrl + D does not help in such case.
Until IDEA does not get a built-in feature like this, you can use this approach (it's pretty quick):
Put caret on the method name line or anywhere inside the method itself
Ctrl + Minus
Ctrl + D
Ctrl + Plus
Or make a Macro like #CrazyCoder suggested.
You can use first Ctrl + W to select method. Then Ctrl + D to duplicate selected lines.

What is the shortcut in IntelliJ IDEA to find method / functions?

I know that Ctrl + N is to find classes and it is very useful. But what about methods?
ctrl + F12 (cmd + F12 on macOS) will show all members of the current class in a popup window and let you pick up one. It works exactly like the ctrl + o shortcut in eclipse, much faster than ctrl + alt + shift + n
Windows : ^ ctrl + F12
MacOS : ⌘ cmd + F12
Above commands will show the functions/methods in the current class.
Press ⇧ SHIFT TWO times if you want to search both class and method in the whole project.
Ctrl + Alt + Shift + N allows you to search for symbols, including methods.
The primary advantage of this more complicated keybinding is that is searches in all files, not just the current file as Ctrl + F12 does.
(And as always, for Mac you substitute Cmd for Ctrl for these keybindings.)
Android Studio on Mac
Command + Option + O
Opens up the Symbol lookup that you can jump to most of the methods/functions in your currently opened document.
Intellij IDEA 2017.3.4 - 2018.2 (Ultimate) on OSX
CMD + fn + F12
will show all members of the current class in a popup window, then you can search method in that class.
BUT, this answer is depends on your Keyboard setting. If your keyboard setting in
System Preferences > Keyboard > Use all F1, F2, etc. keys as standard function keys
is selected, then the shortcut becomes
CMD + F12
CTRL + F12 brings up the File Structure navigation menu, which lets you search for members of the currently open file.
IntelliJ IDEA Version 12.13 Ultimate Edition:
Macs:
command + option + shift + N
or on Menu -> Navigate > Symbol ...
Slightly beside the actual question, but nonetheless useful: The Help menu of Intellij has an option 'Default Keymap reference', which opens a PDF with the complete mapping. (Ctrl+F12 is mentioned there)
If you just want to look for methods:
On mac OS X 10.5+ binding, it is Alt + ⌘ + O
By Default XWin Key binding, it is Shift + Ctrl + Alt + N
You can also press double SHIFT then, you can search anything (not only method, but also class, files, and actions)
It is worth adding that if you want to search for a method of a class, you can use a . (dot) between the class and method name inside of either the search everywhere or search symbols dialog. This even works with IDEAs usual search benefits. For example, you can search for LDT.now and LocalDateTime::now will pop up as a result. (As long as you are searching All Files and not just Project Files).
If you click on a method, you can do Ctrl + B to go to that method's declaration. Similar to F12 in MS Visual Studio.
To Find the actions build in the IDEA(reindent, create new, ...) you can use
CRTL+SHIFT+A
then type indent for example and ENTER.
If I need navigate to method in currently opened class, I use this combination: ALT+7 (CMD+7 on Mac) to open structure view, and press two times (first time open, second time focus on view), type name of methods, select on of needed.
Intellij v 13.1.4, OSX
The Open Symbol keyboard shortcut is
command+shift+s
Ctrl + Shift + Alt+ 7 after selecting the method
I tried SHIFT + SHIFT and ALT + CMD + O
But I think the most powerful and easy to use feature is find in all files CMD + SHIFT + F.
Choose regex and write .*partOfMethodName.*\( and it shows all places and can see the actual source code in place without going to that specific file.