Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the IntelliJ shortcut key to insert the tag code in a javadoc comment?

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?

like image 796
Miguel Gamboa Avatar asked Sep 06 '16 10:09

Miguel Gamboa


2 Answers

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.

like image 52
Bas Leijdekkers Avatar answered Oct 13 '22 18:10

Bas Leijdekkers


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

  1. On the main menu, choose Tools | Generate JavaDoc. Generate JavaDoc dialog is opened.
  2. 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.
  3. Specify the other JavaDoc options. Refer to the topic Generate JavaDoc Dialog for description of controls.
  4. 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

like image 2
piotrek1543 Avatar answered Oct 13 '22 16:10

piotrek1543