Autocompletion of @author in Intellij

Intellij IdeaJavadoc

Intellij Idea Problem Overview


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?

Intellij Idea Solutions


Solution 1 - Intellij Idea

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

Solution 2 - Intellij Idea

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

Solution 3 - Intellij Idea

Check Enable Live Templates and leave the cursor at the position desired and click Apply then OK

enter image description here

Solution 4 - Intellij Idea

For Intellij IDEA Community 2019.1 you will need to follow these steps :

> File -> New -> Edit File Templates.. -> Class -> /* Created by ${USER} > on ${DATE} */

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionrkcpiView Question on Stackoverflow
Solution 1 - Intellij IdealeveluptorView Answer on Stackoverflow
Solution 2 - Intellij IdeaLennartView Answer on Stackoverflow
Solution 3 - Intellij IdeaTarekBView Answer on Stackoverflow
Solution 4 - Intellij IdeaSuditi ChoudharyView Answer on Stackoverflow