Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind multiple actions to a shortcut

Each time I finished editing a Java class, I want to : Organize imports, Reformat code and Rearrange code. I have to hit 3 keyboard shortcuts.

Is there a way to assign a chain of actions to a single shortcut ?

I am using IntelliJ 14.1.5.

like image 546
Comencau Avatar asked Oct 05 '15 11:10

Comencau


People also ask

How do I assign keyboard shortcuts?

Assign a shortcut key to that Windows shortcut Right-click the shortcut and select Properties. Click the Shortcut tab. Click in the Shortcut key box and press a letter. For example, if you press the P key, the key combination to run this shortcut is Ctrl + Alt + P .

What is action shortcut?

You can assign an F key or “Function key” keyboard shortcut for any action. To do so, select your action from the Actions Panel, then double click on the space next to the action name to bring up the Actions Options. Then select the F key that you would like to use from the Function Key drop down menu.


Video Answer


1 Answers

You can record a macro consisting of the actions you want to perform and assign a shortcut to that macro.

The process is described here. For the sake of completeness, here are the steps from these online guides (credit goes to Jetbrains):

To record a macro

  • On the main menu, choose Edit | Macros | Start Macro Recording. From that moment on, all your recordable actions are recorded.
  • When you are done with the procedure, choose Edit | Macros | Stop Macro Recording.
  • In the Enter Macro Name dialog, specify the name of the new macro, and click OK. If the macro is intended for temporary use only, you can leave the name blank.

To bind a macro with a keyboard shortcut

  • Open the Settings dialog and click Keymap.
  • Create a new keymap Run/Debug Configuration: PHP Script or select an editable keymap from the list of keymaps.
  • Expand the Macros node and select the macro for which a keyboard shortcut should be created.
  • Right-click on the macro and choose Add Keyboard Shortcut in the context menu.
  • In the Enter Keyboard Shortcut dialog, press the keys to be used as a shortcut. The keystrokes are immediately reflected in the First Stroke field. Optionally, select the Second stroke check box and specify the second stroke. As you press the keys, the Preview field displays the keystrokes you pressed, and the Conflicts field displays warnings, if the keystrokes are already in use.
  • Click OK using the mouse pointer to create a shortcut and bind it with the macro.
  • Click Apply to save the settings.
like image 78
Bohuslav Burghardt Avatar answered Sep 28 '22 08:09

Bohuslav Burghardt