Managing Code Style on a Directory Level with EditorConfig
As we announced a short while ago, in the upcoming version 2019.2, IntelliJ IDEA and other IntelliJ-based IDEs are extending EditorConfig support, thus allowing you to manage all code style settings for each set of files individually. All you need to do is place an
.editorconfig file in the root directory containing the files whose code style you want to define. You can have as many
.editorconfig files within a project as needed, so you can specify different code styles for different modules. All options from the
.editorconfig file are applied to the directory where it resides as well as all of its sub-directories on top of the current project code style defined in Settings/Preferences | Editor | Code Style. If anything is not defined in
.editorconfig, it’s taken from the project settings.
In v2019.2, in addition to the standard EditorConfig options, we are adding a bunch of custom IntelliJ IDEA options, so now you can conveniently manage all your code style settings on the directory level.
The options are divided into the following categories:
- Standard options such as
indent_style, and so on. These options do not have any domain-specific prefixes.
- Generic IntelliJ IDEA options that have the
ij_prefix and are applicable to all languages:
- Common IntelliJ IDEA language options supported by many (but not all) languages. They start with the
ij_anyprefix, for example,
- IntelliJ IDEA language-specific options starting with the
<lang>is the language domain ID (normally a lower-case language name). For example,
Note: The same options may be defined as a common option and a language-specific option, for example,
ij_<...>_brace_style. Language-specific options have higher priority over common or generic options.
Try it Out
Let’s give this feature a try using the
- In the Project view, select a source directory and select New | EditorConfig File from the context menu:
- To create an empty file, do not select any properties in the dialog that opens:
- Add the following line:
ij_visual_guides = 40,60(once you start typing, code completion will suggest the available properties). You will immediately see visual guides appear at columns 40 and 60:
Preview Code Style Settings
You can now easily preview how changes to your code style settings will impact the actual source files. To do this, click the eye icon in the left gutter of the
EditorConfig file and select a source file affected by it. The preview of this file will open on the right:
You can make changes in the Preview pane to try and test how your configuration changes are reflected without worrying about making unwanted changes to the source code – all these changes are discarded when the
EditorConfig file is closed.
Subscribe to Blog updates
Thanks, we've got you!
Import Postman Collections to the HTTP Client
We know that many of you use Postman collections and want to stay in the flow while working with them. This means staying inside IntelliJ IDEA and not switching to a different app. Great news! You can now effortlessly transform Postman collections into .http and use them in the HTTP Client …
What’s New in IntelliJ IDEA 2023.1 for Spring Developers
The IntelliJ IDEA 2023.1 release came packed with updates for Spring. This blog post will highlight the most noticeable changes, including full support for Lombok, a reworked Spring tool window, navigation for Spring Security rules, Spring Security 6 support, and more. Remember that these featur…
‘Quick’ Features in IntelliJ IDEA
A few IntelliJ IDEA features or actions include the term ‘quick’. Do they speed up certain processes? Let’s find out. In this blog post, I’ll cover what these features are, why you need them, and how you can use them. 1. Quick Lists If you have actions that you use regularly but don’t have shortcut…
5 Best Features for Profiling Java Code In IntelliJ IDEA
When it comes to apps functioning efficiently, there is always room for improvement. Fast, lag-free, smooth operation – what else can a Java developer dream of? However, when you aim for this level of perfection in your app, you will need a comprehensive toolset to monitor performance and identif…