Using Macros in the Editor
Macros provide a convenient way to automate repetitive procedures you do frequently while writing code. You can record, edit and playback macros, assign them a shortcut, and share them. Generally speaking, macros are designed for rather simple operations, and as such have the following limitations:
- Macros can be used for editor-related actions within a file.
- You cannot record such actions as button clicks, navigating to pop-up dialog boxes, and accessing tool windows or menus.
If a macro is intended for temporary use only, it is unnamed; permanent macros have unique names.
Record a macro
- On the main menu, choose . From that moment on, all your recordable actions are recorded.
- When you are done with the procedure, choose .
- 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.
After recording, you can remove or rename any or all of the macros from the list of available macros. The actions list of each macro is also editable & you can remove unnecessary actions.
- On the main menu, choose .
- In left-hand pane of the Edit Macros dialog, select the macro to be edited or deleted:
- To delete a macro, click. To change the macro name, click, and specify the new name in the Rename Macro dialog.
- To change the list of actions for a macro, select an action in the action list, and click .
Play back a macro
- To play back a temporary macro, choose in the main menu.
- To play back a named macro, choose in the main menu.
- To play back a macro with a keyboard shortcut, assign a shortcut to the macro and use this shortcut.
Bind a macro with a keyboard shortcut
- Press ⌘, or choose from the main menu, and then go to .
- Create a new keymap or select a keymap from the list of keymaps.
- Expand the Macros node and select the macro for which a keyboard shortcut should be created.
- Right-click 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 checkbox 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.
It is important that you use the mouse pointer, because any keystroke is interpreted as a shortcut.
- Click OK using the mouse pointer to create a shortcut and bind it with the macro.
- Apply changes.