如何将多个操作绑定到快捷方式
How to bind multiple actions to a shortcut
每次我完成 Java class 的编辑时,我想:组织导入、重新格式化代码和重新排列代码。我必须按 3 个键盘快捷键。
有没有办法将一系列操作分配给单个快捷方式?
我正在使用 IntelliJ 14.1.5。
您可以录制一个包含您要执行的操作的宏,并为该宏指定一个快捷方式。
过程描述 here。为了完整起见,以下是这些在线指南中的步骤(归功于 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.
每次我完成 Java class 的编辑时,我想:组织导入、重新格式化代码和重新排列代码。我必须按 3 个键盘快捷键。
有没有办法将一系列操作分配给单个快捷方式?
我正在使用 IntelliJ 14.1.5。
您可以录制一个包含您要执行的操作的宏,并为该宏指定一个快捷方式。
过程描述 here。为了完整起见,以下是这些在线指南中的步骤(归功于 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.