Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Autocompletion of @author in Intellij

I'm migrating from Eclipse to Intellij Idea. One thing I couldn't figure out yet is autocompletion of the @author JavaDoc tag. When typing @a in Eclipse, there are two proposals:

@author - author name @author 

How do I achieve the first proposal in Intellij (is it even possible?)? And if it's possible, how do I change the template of what is inserted for the author name placeholder?

like image 980
rkcpi Avatar asked Sep 11 '13 09:09

rkcpi


People also ask

How do I set default comments in IntelliJ?

Add a new commentType /** 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 turn off auto complete in IntelliJ?

By default, IntelliJ IDEA displays the code completion popup automatically as you type. If automatic completion is disabled, press Ctrl+Shift+Space or choose Code | Code Completion | Type-Matching from the main menu. If necessary, press Ctrl+Shift+Space once again.

How do I turn on auto suggestion in IntelliJ?

Press Ctrl+Alt+S to open the IDE settings and select Editor | General | Code Completion. To automatically display the suggestions list, select the Show suggestions as you type checkbox.


2 Answers

One more option, not exactly what you asked, but can be useful:

Go to Settings -> Editor -> File and code templates -> Includes tab (on the right). There is a template header for the new files, you can use the username here:

/**  * @author myname  */ 

For system username use:

/**  * @author ${USER}  */ 

Screen shot from Intellij 2016.02

like image 152
leveluptor Avatar answered Sep 20 '22 09:09

leveluptor


You can work around that via a Live Template.

Go to Settings -> Editor -> Live Templates, click the Plus Icon Button (on the right).

In the "Abbreviation" field, enter the string that should activate the template (e.g. @a), and in the "Template Text" area enter the string to complete (e.g. @author - My Name). Set the "Applicable context" to Java (Comments only maybe) and set a key to complete (on the right).

I tested it and it works fine, however IntelliJ seems to prefer the inbuild templates, so "@a + Tab" only completes "author". Setting the completion key to Space worked however.

To change the user name that is automatically inserted via the File Templates (when creating a class for example), can be changed by adding

-Duser.name=Your name

to the idea.exe.vmoptions or idea64.exe.vmoptions (depending on your version) in the IntelliJ/bin directory.

enter image description here

Restart IntelliJ

like image 36
Lennart Avatar answered Sep 18 '22 09:09

Lennart