Recording a Macro

A macro consists of a series of commonly used keystroke combinations, which are invoked by a simpler keystroke. The Java Source Editor comes with a few predefined macros. You can define your own macro by recording a series of keystrokes.

To record a Source Editor macro:

  1. Open a file in the Source Editor. The macro you record will be available for all other files of the same type.
  2. Determine the keystroke sequence required to repeat the task you want your macro to accomplish. It might be helpful to write this sequence down before recording your macro.

    You should not use the mouse while recording a macro. If any of the steps of your macro cannot be done with a keyboard shortcut, create a shortcut for that step as described in Setting Keyboard Shortcuts.

  3. Position the insertion point in the Source Editor where you want to begin recording your macro.
  4. Type Ctrl-J, S to start recording.

    "Recording" appears in the Source Editor status line.

  5. Use keystrokes to perform the steps of your macro.
  6. Type Ctrl-J, E to end recording.

    The Recorded Macro dialog box is displayed.

  7. Type a name for your macro in the Name field.
  8. If desired, edit the keystroke sequence shown in the Macros field. This displays the actions taken during the macro recording, as defined in the Key Bindings property editor.
  9. Click the Add Shortcut Sequence button.

    The Add Shortcut Sequence dialog box is displayed. Press the key sequence you want to use to run this macro in the Shortcut Sequence field, and click OK.

    As you press the key sequence, the correct syntax for that sequence automatically appears in the text field. For example, if you simultaneously hold down the Alt key, the Control key, and the J key, "Ctrl+Alt+J" appears.

  10. Click OK in the Recorded Macro dialog box. Your macro can now be run using the keyboard shortcut you specified in the previous step.
While recording a macro, do not rely on time-out features like the automatic display of the Code Completion box. The time-out will not happen during playback. If you want to use the code completion box in a macro, display it explicitly while recording using Ctrl-spacebar.
Note
See also
Editing a Macro
Running a Macro
Key Bindings Property Editor
Using Code Completion

Legal Notices