Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse-like comment formatting in IntelliJ IDEA?

In Eclipse, I can format comments by selecting them and pressing Shift + Ctrl + F. For example, when I select a method comment like this:

/**  * This method  * does some stuff.  */ 

and press Shift + Ctrl + F, Eclipse automatically wraps it:

/**  * This method does some stuff.  */ 

Is there anything comparable to this in IDEA?

EDIT: To clarify, I'm looking for comment formatting that also breaks lines that are too long into multiple lines.

like image 334
python dude Avatar asked Jul 25 '11 08:07

python dude


People also ask

How do I set default comments in IntelliJ?

Add a Javadoc using automatic commentsType /** before a declaration and press Enter . The IDE auto-completes the doc comment for you. For information on how to disable this feature, refer to Disable automatic comments.

How do I beautify my code in IntelliJ?

Go to Settings/Preferences | Editor | Code Style, select your programming language, and open the Wrapping and Braces tab. In the Keep when reformatting section, select the formatting rules which you want to ignore and deselect those which should be applied. Reformat your code ( Ctrl+Alt+L ).

How do I fix indentation in IntelliJ?

Just press Alt + Ctrl + I (Alt + Cmd + I for Mac) shortcut and it will quickly fix indents for the current line. Read the complete article to learn more on the code style and formatting in IntelliJ IDEA.


1 Answers

The closest thing that you can get is Edit | Join Lines (Ctrl+Shift+J). You have to select the lines you want to join first.

To wrap long comments enable Settings | Code Style | JavaDoc | Wrap at right margin.

like image 90
CrazyCoder Avatar answered Sep 27 '22 18:09

CrazyCoder