Some shortcuts can be integrated into ideaVIM, but some are more complicated and need other tricks to make it more handy. One of the technique is to use macros. As Mac's Automator, you can ask Intellij or Android Studio to record your actions, and make it available as a keyboard shortcut.
For example, if you want to add javadoc comment to a funtion, you need to move to the first line of a certain function, and type in /**. After pressing Enter, it will generate javadoc template for that specific function. Though it's already very convenient, it still takes time if you're not quite familiar with how to move the cursor to the first line of the function.
So, to add javadoc comment from anywhere in codes, you can record a macro to move to the first line of the func, and type /** , and Enter for you. Here's the actions:
- 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
And then you can add a keyboard shortcut for this macro in Keymapping in Preferences.
REF:
沒有留言:
張貼留言