Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android Studio: how to remove/update the "Created by" comment added to all new classes?

By default Android Studio automatically adds a header comment to all new classes, e.g.

/**
 * Created by Dan on 11/20/13.
 */

Where is the setting to customize or remove it?

like image 302
Dan J Avatar asked Oct 05 '22 09:10

Dan J


2 Answers

From the menu bar:

  • on Mac OS choose Android Studio -> Preferences
  • on Windows and Linux choose File -> Settings

Then look for Editor -> File and Code Templates in the left hand pane.

You have two ways you can change this...

1) Select the Includes tab and edit the Created by... text directly.

enter image description here

2) Select the Templates tab and edit the #parse("File Header.java") line for any template that you desire.

templates tab edit

Personally I followed option 1) and made the default header comment a TODO, e.g.

/**
 * TODO: Add a class header comment!
 */

These instructions are based on Android Studio v0.3.7. and also tested on v1.2.1.1

like image 430
Dan J Avatar answered Oct 06 '22 21:10

Dan J


You can overwrite the ${USER} variable in the template file with the #set( $VARIABLE = "value") function.

On windows: Press Ctrl+Alt+S and go to Settings -> File and Code Templates -> Includes -> File Header

On Mac: Android Studio -> Preferences -> Editor -> 
File and Code Templates -> Includes -> File Header

prepend the #set() function call, for example:

#set( $USER = "YourName" )
/**
* Created by ${USER} on ${DATE}.
*/
like image 76
Cüneyt Avatar answered Oct 06 '22 22:10

Cüneyt