In this area,
choose the code style scheme and change it as required.
Settings of a code style scheme are automatically applied every time DataGrip generates,
refactors, or reformats your code.
The code styles are defined at the project level and at the
IDE level (global).
At the Project level, settings are grouped under the Project
scheme, which is predefined and is marked bold. The Project style scheme applies to
the current project only.
You can copy the Project scheme to the IDE level, using the command
Copy to IDE....
At the IDE level, settings are grouped under the predefined
Default scheme (marked bold), and any other scheme created by the user by the command
Dulpicate (marked plain text). The global settings are used when the user doesn't
want to keep code style settings with the project and share them.
You can copy the IDE scheme to the current project, using the command
Copy to Project.... So doing, the following dialog box appears:
Clicking Yes results in overwring the project code style settings, clicking
No cancels the operation.
From this drop-down list, select the scheme to be used. The predefined schemes are
shown bold. The custom schemes, ones created as copies of the predefined schemes,
are in plain text. Next to each scheme it is written where the scheme is stored, for example, the
Default scheme is stored in the IDE, the Project scheme is stored
with the project.
Click this button to reveal the drop-down list of commands to you manage the schemes:
Copy to IDE...
Choose this command to copy the scheme settings to the IDE.
Choose this command to export the selected scheme to an xml file in the selected
Project and IDE
Choose this command to import the scheme of the selected type from the specified location:
Project and IDE
Copy to Project...
Choose this command to copy the scheme settings to be stored with a project.
Choose this command to create a copy of the selected scheme.
Choose this command to reset the default or bundled color scheme to the initial defaults
shipped with DataGrip. This command becomes available if only some changes have been done.
Choose this command to change the name of the selected custom scheme. Press
Enter to save changes, or Escape to cancel.
DataGrip lets you
configure line separator and indentation options for various languages.
reformatting source code,
DataGrip will apply the specified indentation behavior and skip
the sections denoted with the special formatting off/on markers.
Line Separator (for new files)
Use this drop-down list to specify which line separator is to be used in files created by DataGrip.
The available options are:
System dependent - choose this option to use the default selection.
Unix and macOS (\n) - choose this option to use the Unix and macOS line
Windows (\r\n) - choose this option to use the Windows line separator.
Classic Mac (\r) - choose this option to use the Classic Mac line
Right Margin (columns)
In this text box, specify the number of columns to be used to display pages in the editor.
Wrap when typing reaches right margin
Select this check box to ensure that edited text always fits in the specified right margin.
Use this area to specify default options for indentation.
Detect and use existing file indents for editing
Select this check box for DataGrip to detect the existing indents in the file and use them for
editing instead of the indents specified in the Code Style settings for the specific language.
Show notifications about detected indents
Select this check box to show a notification if DataGrip detects indents that are different from
the ones specified in the Code Style settings for the specific language.
If this check box is selected, the fragments of code between the line comments with the
formatting markers will not be reformatted but will preserve the original formatting.
After you select the check box, the fields below become available and you can specify the
character strings to be treated as formatting markers.
If the check box is cleared, the formatting markers will be ignored and the code between the
line comments with markers will be reformatted.
In this text box, specify the character string that will indicate the beginning of a code fragment
which you want to exclude from reformatting. Type a character string with the @ symbol
in preposition or leave the predefined value @formatter:off.
In this text box, specify the character string that will indicate the end of a code fragment which
you want to exclude from reformatting. Type a character string with the @ symbol in
preposition or leave the predefined value @formatter:on.
Select this check box to use regular expressions instead of specifying the formatting markers
explicitly. DataGrip matches formatter on/off markers using the regular expression specified
instead of the exact string.
Example of using formatting markers
The original source code
The code after reformatting
When the formatting markers are disabled, the original formatting is broken:
When the formatting markers are enabled, the original formatting is preserved:
In this area enable the support of the EditorConfig plugin.
Enable EditorConfig support
Select this check box to enable the EditorConfig plugin support. In this case you can specify your own code style settings that override the IDE settings.
However, if you decide to use IDE settings after creating the EditorConfig settings file then you need clear the Enable EditConfig support check box.
See also Configuring Code Style procedure.
Click this button if you want to export the current IDE code style settings into the .editconfig file.