Search code examples
intellij-ideacommentskeyboard-shortcutsjavadoc

How can I shift my code left and right inside multiline comments in IntelliJ IDEA?


I am writing a Javadoc and I want to shift my code left and right, but of course, it just shifts the whole line of code, not the commented content.

Is it possible to shift a comment's content with keyboard shortcuts, or is the only way to do so manually?

What I want to shift:

/**
 *     content
 */

How it shifts with Shift + Tab:

/**
*     content
 */

How I want it to be:

/**
 * content
 */

Solution

  • In IntelliJ IDEA, this is defined by Code Styles. In Java specifically, this is controlled by the "Continuation Indent" ("Tabs and Indents" tab) and the options on the JavaDoc tab. So if you are looking to change indents for all JavaDoc lines, this is the option for you.

    One more option is to record a macro deleting extra spaces and assigning a hotkey for it as described here.