Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to share Code Style settings between developers in IntelliJ

I would like all developers on my team to use the same default code style settings. We all use IntelliJ 11+ as our IDE and we use git as our source control system.

What is the easiest way to make sure they're all using the same settings? I thought there would be a way to check in the style settings into the project and have their editors discover them automatically, but that doesn't seem to be the case.

PS. I don't mind if developers consciously override some of the default settings with their own preferences, but I do want to make sure that we all at least start from a common set of default settings.

like image 770
emmby Avatar asked Jan 31 '12 21:01

emmby


People also ask

How do I sync my IntelliJ settings?

and select Enable Sync. Alternatively, select File | Manage IDE Settings | Sync Settings to JetBrains Account from the main menu. In the dialog that opens, click the Enable Settings Sync button. Your local settings will be exported to the JetBrains repository linked to your account.

How do I copy IntelliJ settings?

Choose File | Manage IDE Settings | Export Settings from the main menu. In the Export Settings dialog that opens specify the settings to export by selecting the checkboxes next to them.

How do I fix code style in IntelliJ?

In the editor, select a code fragment you want to reformat. Before reformatting, you can take a look at the code style settings that are applied to the selected code: press Alt+Enter and click Adjust code style settings. From the main menu, select Code | Reformat Code or press Ctrl+Alt+L .


2 Answers

Code Style can be copied to project and saved in .idea/codeStyles to be shared via version control:

Copy to Project Click this button to create a copy of the current global scheme to the project level. After creating the copy, IntelliJ IDEA suggests to switch to this new scheme at the project level.

like image 190
CrazyCoder Avatar answered Sep 20 '22 11:09

CrazyCoder


The Settings Repository feature was introduced at IntelliJ IDEA 2016.

This option helps us to share IDE settings between different computers, including sharing settings between developers.

The settings are stored at Git repository, for example on GitHub or Bitbucket.

To setup Git repository we should set URL via Settings Repository menu option.

Calling settings

The developer can load remote settings, overwrite remote settings or merge local settings with remote ones.

Set url and choose action

The structure of Git repository with settings:

Git repository structure

I used personal access token for GitHub authentication.


More information:

  • Settings Repository
  • Creating a personal access token for the command line
like image 27
Alex K Avatar answered Sep 23 '22 11:09

Alex K