How to bind multiple actions to a shortcut

核能气质少年 提交于 2019-12-12 08:27:06

问题


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.


回答1:


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.


来源:https://stackoverflow.com/questions/32948061/how-to-bind-multiple-actions-to-a-shortcut

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!