2013/06/07

Adding macros in Android Studio (Intellij) -- take Adding Javadoc comment for example

(Geneve.Swiss) Climbing is pleasant, but it leads you to better views.

 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:
  1. Start recording a a macro in Edit - Macros - Start Macro Recording
    1. Press Down
    2. Press Ctrl + Up
    3. Press ⌘ + Left
    4. Write /**
    5. Press Enter
  2. Stop the macro recording in Edit - Macros - Stop Macro Recording
  3. Give it a cool name
And then you can add a keyboard shortcut for this macro in Keymapping in Preferences.

REF:

沒有留言:

張貼留言

跨界通訊 - 陳又津

昨天從圖書館借的書,一口氣把它看完了。很特別的題材,在講老人的社會問題,以及人為什麼不行自行決定生死,只能在醫院拖著已經殘破不堪的身體,直到最後短氣的那一刻。 書中還有提到想成為女生的男生,以及透過網路可以達到的一些社群效果。算是把一些現代的元素組合得蠻好的作品。 推薦。