javaintellij-ideaconstructorautocompleteauto-generate

How to change code generation settings in IntelliJ?


I have the following variables in an object:

private String mName;
private String mArtist;
private String mWhosampledPage;
private String mImage;
private List<Pair<String, String>> mSamples;
private List<Pair<String, String>> mSampledIn;
private List<Pair<String, String>> mCovers;
private List<Pair<String, String>> mRemixes;

I want to use Alt+Insert in IntelliJ to auto generate a constructor and when I do that, this is what gets generated:

public Song(String mName, String mArtist, String mWhosampledPage, String mImage, List<Pair<String, String>> mSamples, List<Pair<String, String>> mSampledIn, List<Pair<String, String>> mCovers, List<Pair<String, String>> mRemixes) {
    this.mName = mName;
    this.mArtist = mArtist;
    this.mWhosampledPage = mWhosampledPage;
    this.mImage = mImage;
    this.mSamples = mSamples;
    this.mSampledIn = mSampledIn;
    this.mCovers = mCovers;
    this.mRemixes = mRemixes;
}

How can I change the generate settings such that the constructor created looks more like this:

public Song(String name, String artist, String whosampledPage, String image, List<Pair<String, String>> samples, List<Pair<String, String>> sampledIn, List<Pair<String, String>> covers, List<Pair<String, String>> remixes) {
    mName = name;
    mArtist = artist;
    mWhosampledPage = whosampledPage;
    mImage = image;
    mSamples = samples;
    mSampledIn = sampledIn;
    mCovers = covers;
    mRemixes = remixes;
}

I know this is possible as I have made use of it in other IntelliJ configurations (different devices) but I am not sure how to make the switch.

Thank you


Solution

  • Go to the settings Preferences | Editor | Code Style | Java and under the tab Code Generation set the Field Name prefix to m.