- Opening the Source Editor
- Managing Automatic Insertion of Closing Characters
- Displaying Line Numbers
- Generating Code Snippets without Leaving the Keyboard
- Using Code Completion
- Inserting Snippets from Code Templates
- Using Editor Hints to Generate Missing Code
- Matching Other Words in a File
- Generating Methods to Implement and Override
- Generating JavaBeans Component Code
- Creating and Using Macros
- Creating and Customizing File Templates
- Handling Imports
- Displaying Javadoc Documentation While Editing
- Formatting Code
- Text Selection Shortcuts
- Navigating within the Current Java File
- Navigating from the Source Editor
- Searching and Replacing
- Deleting Code Safely
- Changing a Method's Signature
- Encapsulating a Field
- Moving a Class to a Different Package
- Moving Class Members to Other Classes
- Creating a Method from Existing Statements
- Creating an Interface from Existing Methods
- Extracting a Superclass to Consolidate Common Methods
- Changing References to Use a Supertype
- Unnesting Classes
- Tracking Notes to Yourself in Your Code
- Comparing Differences Between Two Files
- Splitting the Source Editor
- Maximizing Space for the Source Editor
- Changing Source Editor Keyboard Shortcuts
Creating and Using Macros
You can record macros in the IDE to reduce what would normally involve a long set of keystrokes to one keyboard shortcut. In macros, you can combine the typing of characters in the Source Editor and the typing of other keyboard shortcuts.
To record a macro:
- Put the insertion point in the part of a file in the Source Editor where you want to record the macro.
- Click the button in the Source Editor's toolbar (or press Ctrl-J and then type s) to begin recording.
- Record the macro using any sequence of keystrokes, whether it is the typing of characters or using keyboard shortcuts. Mouse movements and clicks (such as menu selections) are not recorded.
- Click the in the Source Editor's toolbar (or press Ctrl-J and then type e) to finish recording.
- In the Macro field of the Recorded Macro dialog box that appears, fine-tune the macro, if necessary.
- Click Add to assign a keyboard shortcut to the macro.
- In the Add Keybinding dialog box, press the keys that you want to use for the keyboard shortcut. (For example, if you want the shortcut Alt-Shift-Z, press the Alt, Shift, and Z keys.) If you press a wrong key, click the Clear button to start over.
Be careful not to use a shortcut that is already assigned. If the shortcut you enter is an editor shortcut, a warning appears in the dialog box. However, if the key combination is a shortcut that applies outside of the Source Editor, you will not be warned.
You can assign a new shortcut in the Options window. Choose Tools | Options, click the Editor panel, select the Macros tab, and then click the Set Shortcut button.