IntelliJ IDEA 2024.3 Help

Code style schemes

The IDE comes with two pre-defined schemes: the Project scheme and the Default scheme.

  • In the Project scheme, the settings that you configure apply only to your current project.

    These settings are stored in the codeStyles folder under .idea and are shared through VCS together with the project.

    The IDE creates the folder after you modify code style settings for your project.

  • In the Default scheme (IDE-level scheme), the settings that you configure apply to all existing projects that have the Default code style scheme selected.

    These settings are stored in the codestyles folder under the IntelliJ IDEA configuration directory and are not shared through VCS.

If you want to use the project code style scheme as your default scheme, you can copy it to the IDE level. The other way around is also possible: you can overwrite your current project settings with the settings from an IDE-level scheme and share them with other members of your team.

Configure schemes

In IntelliJ IDEA, code style settings are language-specific, so you need to configure them for every language that you use in your project separately. You can also copy the settings from one language and apply them to another language.

Configure a code style scheme

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

    To configure a scheme for new projects, go to File | New Projects Setup | Settings for New Projects | Editor | Code Style.

  2. Select the language for which you want to configure the code style.

  3. Select the code style Scheme that you want to configure: the Project scheme or one of the IDE-level schemes.

  4. Browse through the tabs and configure code style preferences.

    For a detailed description of each setting for Java, refer to Code Style. Java.

    Use the right section of the dialog to preview the changes. When you change a setting, one or several blinking areas appear in the preview area emphasizing the changes.

Apply a predefined code style

In some languages, for example, in PHP, there are predefined coding standards that you can upload to the IDE and apply to your code.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

    To configure a scheme for new projects, go to File | New Projects Setup | Settings for New Projects | Editor | Code Style.

  2. Select the language for which you want to configure the code style.

  3. Select the code style Scheme that you want to modify: the Project scheme or one of the IDE-level schemes.

  4. Click the Set from link, select Predefined, and select one of the pre-configured standard from the list.

Apply code style from another language

For most of the supported languages, you can copy code style settings from other languages or frameworks.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

    To configure a scheme for new projects, go to File | New Projects Setup | Settings for New Projects | Editor | Code Style in the main menu.

  2. Select the language for which you want to configure the code style.

  3. Select the code style Scheme that you want to modify: the Project scheme or one of the IDE-level schemes.

  4. From the list that appears, select the language to copy the code style from.

    Set code style from another language

Copy code style settings

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

    To configure a scheme for new projects, go to File | New Projects Setup | Settings for New Projects | Editor | Code Style in the main menu.

  2. Select the code style Scheme that you want to copy: the Project scheme or one of the IDE-level schemes.

  3. Click the Show Scheme Actions icon and select one of the following options:

    • Copy to IDE (for the Project scheme): copy the selected scheme to the IDE level.

      IntelliJ IDEA saves the new code style with the specified name to the IntelliJ IDEA home directory.

    • Copy to Project (for IDE-level schemes): overwrite your current project settings with the settings from the selected IDE-level profile.

    • Duplicate (for IDE-level schemes): create a copy of the selected IDE scheme on the same level.

    Copying code style scheme settings
  4. In the Scheme field, type the name of the new scheme and press Enter to save the changes.

Import and export schemes

Import a scheme

Out of the box, IntelliJ IDEA allows you to import settings in the IntelliJ IDEA code style XML or Eclipse XML Profile format.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

  2. Click the Show Scheme Actions button and select Import Scheme. Then select the necessary format.

  3. In the dialog that opens, select the file with the settings and click Open.

  4. Rename the scheme if necessary and select Current scheme to apply the settings from the scheme to your code.

Export a scheme

You can export both project-level and IDE-level schemes in the IntelliJ IDEA code style XML, Eclipse XML Profile, or EditorConfig format (if the EditorConfig plugin is enabled).

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

  2. Select the code style Scheme that you want to export: the Project scheme or one of the IDE-level schemes.

  3. Click the Show Scheme Actions button, select Export, select the necessary format, and select the directory to which you want to export your code style settings.

Delete schemes

In IntelliJ IDEA, you cannot delete the bundled Project (project level) and Default (IDE level) code style schemes. You can delete copies of the schemes if you have any. These copies are always IDE-level since you cannot have multiple project schemes.

  1. Press Ctrl+Alt+S to open settings and then select Editor | Code Style.

  2. From the Scheme list, select the scheme that you want to delete.

  3. Click Show Scheme Actions and select Delete.

    Deleting a code style scheme
  4. In the popup that opens, confirm the action by clicking Delete.

Last modified: 11 October 2024