Introduction
The way to add Javadoc to a method in IDEA is to put the cursor above the method and write '/**' and press Enter.
In Eclipse you can use a keyboard shortcut to produce the same result. This can be emulated in IDEA!
Implementation steps
The first thing to do is to create a macro:
- Start recording a a macro in Edit - Macros - Start Macro Recording
- Press Down
- Press Ctrl + Up
- Press ⌘ + Left
- Write /**
- Press Enter
- Stop the macro recording in Edit - Macros - Stop Macro Recording
- Give it a cool name
- Edit the macro in Edit - Macros - Edit Macros, select your new macro and edit it to contain the following:
- Action: EditorDown
- Action: MethodUp
- Action: EditorLineStart
- Typing "/**"
- Action: EditorEnter
Now you can add a keyboard shortcut to the macro:
- Double-click on your macro in Settings - Keymap - Macros - Your macro with the cool name
- Choose Add keyboard shortcut
- Press the keyboard combination that should trigger the macro, e.g. ⌘ + Shift + J
Result
You can now add javadoc to a method using a keyboard shortcut from anywhere within a method.
No comments:
Post a Comment