Quantcast
Channel: Navin Peiris » navinpeiris
Viewing all articles
Browse latest Browse all 10

Sharing (Export/Import) IntelliJ IDEA Code Style Formatters

$
0
0

Unlike Eclipse, IntelliJ doesn’t seem to provide a way to export and import code formatters through the GUI. Instead we need to manually copy a particular file from/to an directory created by IntelliJ to store code styles.

Exporting a Code Style Scheme

The formatting options used by IDEA can be customised through the Code Styles section in the Settings (or Preferences in OS X) window.

After customising the styling rules to what you like, click on the Use per project settings radio button, and click on the Export button. This will bring up a dialog asking for the name of the code style scheme that you’ve created, and once you’ve entered an appropriate name, click on the OK button to save this scheme. This will now create and save a XML file with the given name within the codestyles directory and is equivalent to Eclipse’s export code formatter option, except you cannot specify the location you want the file to be saved. The directory this file is placed in is platform dependent and is listed in the next section.

You can now use this file to share the code formatting rules used in your project with the other members of your team.

Code Style Directory Location

The code styles directory is platform dependent, and is available in the locations listed below. Please note that you need to replace <product-name> with the name and version of IDEA you use.

Mac OS X:

~/Library/Preferences/<product-name>/codestyles/

Linux:

~/.<product-name>/config/codeStyles/

Windows:

<User home>\.<product-name>\config\codeStyles\

Importing a Code Style Scheme

If you want to use a code style scheme that was created and shared by someone else, then simply copy the file over to the relevant codestyles directory for your platform as listed in the previous section. After restarting the IDE, you should see this new scheme under the Code Styles section in the Settings window.



Viewing all articles
Browse latest Browse all 10

Trending Articles