I would like to have a fast way to format text as code while I am writing a comment. In Javadoc to format text as code you must include text inside a {@code … }
tag. However, it is a little bit tedious to type braces and then @ and after that the text. So it would be nice if there was a shortcut key to achieve it more quickly.
What is the simplest way in IntelliJ to insert a {@code .... }
in a javadoc comment?
Create a new surround Live Template with an abbreviation you can remember (e.g. S
for source code). Description something like Surround with {@code ...}
. Template text: {@code $SELECTION$}
. Applicable in Java | Comment
.
Now you can select any text you want to surround with {@code ...} and invoke Code | Surround With...
(Ctrl+Alt+T followed by your abbreviation) to format it.
I've already noticed that there's already a tutorial how to generate JavaDoc reference for a Project, which tells, that:
To generate project documentation
- On the main menu, choose Tools | Generate JavaDoc. Generate JavaDoc dialog is opened.
- In the Generate JavaDoc dialog, specify the following options:
- Select scope (whole project or a certain project with subpackages).
- Specify the output directory, where the generated documentation will be placed.
- Use the slider to define the level of visibility of members to be included in the generated documentation.
- Specify the other JavaDoc options. Refer to the topic Generate JavaDoc Dialog for description of controls.
- Click OK.
From: https://www.jetbrains.com/help/idea/2016.2/generating-javadoc-reference-for-a-project.html
but in mentioned Generate JavaDoc Dialog
there's no {@code .... }
scope provided...
What is the simplest way in IntelliJ to insert a {@code .... } in a javadoc comment?
I think the easiest way would be creating live template to later use.
Just go to Settings -> Live Templates
, choose Templates Group
, create JAVADOC
templates group, then add yours JavaDoc code
template.
Hope it will help
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With