In Eclipse, I can press Alt+Shift+J and get a javadoc comment automatically generated with fields, returns, or whatever would be applicable for that specific javadoc comment. I'm assuming that IntelliJ IDEA has this feature. Can anyone tell me if there is a keyboard shortcut for this?
3 Answers
Typing /**
+ then pressing Enter above a method signature will create Javadoc stubs for you.
-
3When overriding a method, eclipse adds an @see tag with a link to the parent method. Can IntelliJ do the same?– ΚαrτhικDec 1, 2014 at 18:28
-
4@RachelGallen link is dead, see jetbrains.com/help/idea/creating-documentation-comments.html– boardtcNov 21, 2018 at 14:24
-
1@boardtc thanks for the update. I actually tried to revisit the link recently and the whole site was down. Nice one. Nov 21, 2018 at 14:28
-
5
You can use the action 'Fix doc comment'. It doesn't have a default shortcut, but you can assign the Alt+Shift+J shortcut to it in the Keymap, because this shortcut isn't used for anything else.
By default, you can also press Ctrl+Shift+A two times and begin typing Fix doc comment
in order to find the action.
-
7For anyone else searching for how to get IntelliJ to update javadoc after a code change, you can set this in Settings -> IDE Settings -> Keymap. Oct 9, 2013 at 1:50
-
-
1Do I have to select something? Even if I select the whole file content or select nothing, nothing happens if I run this action. May I am missing something Jun 18, 2019 at 11:46
-
2@Honsa Stunna we have to exactly click the method line and go for action. Aug 10, 2019 at 11:10
-
1
Shortcut Alt+Enter shows intention actions where you can choose "Add Javadoc".
-
2I think that 3 could disagree with that statement. You should set pointer on the name. Mar 16, 2017 at 13:05
-
4put the cursor on the method name you want to add javadoc ,and then press alt + enter, there will be an add javadoc option in the popup.If the method already has a javadoc,then there will be no add javadoc option. Jun 12, 2017 at 3:11
-
2The only confusion I saw is people asking to put the cursor in function/class/variable to generate java docs. You have to keep the cursor on the object for which you are generating the documentation, just the way you will import a class by keeping cursor on the object and hit
Alt
+Enter
– DoogleFeb 2, 2019 at 14:15 -
Getting to the intention is fine and all, but the goal is - what keymap can I use to add the comment without having to do extra stuff, thus the answer above - adding the keymapping to "Fix doc comment" is the correct answer for someone coming from Eclipse Aug 13, 2021 at 18:55
-
@user1742058 Yes, you're right, but there are many people that found that answer helpful. Furthermore, The accepted answer is also not a shortcut. I think that all 3 answers are good and everyone could pick one. Aug 23, 2021 at 11:08