Code style and EditorConfig
Indentation, tab width and the right margin come from three places, in this order: the project’s
.editorconfig, the project’s code style from an IntelliJ-based IDE, and your own Code Style
settings. Code style and EditorConfig: Works.
Set your own code style
Section titled “Set your own code style”Settings › Editor › Code Style has:
- Hard wrap at: the right margin, 40 to 400 columns, 120 by default, and Show the right margin to draw it.
- One row per language (Default, C/C++, CSS, Go, HTML, Java, JavaScript, JSON, Kotlin, Less, Markdown, Python, Ruby, Rust, SCSS, SQL, TypeScript, YAML) with tabs or spaces, the indent and the tab width. Out of the box, Go uses tabs; JSON, YAML, Ruby, SCSS and Less use 2 spaces; the others 4.
These settings are yours and hold for every project, unless the project says otherwise. Ferris IDEA also looks at the file itself: a file indented with tabs keeps getting tabs.
Code Style covers indentation and the margin. Where to break lines, spaces around operators and blank lines are the formatter’s business: Reformat code.
EditorConfig
Section titled “EditorConfig”A project’s .editorconfig comes before your settings for the files it matches. Ferris IDEA reads
.editorconfig files from the file’s folder upward until one says root = true, and supports:
| Property | Effect |
|---|---|
indent_style, indent_size, tab_width |
indentation when you type, paste and reformat |
max_line_length |
where the right margin is drawn (off for none); lines are not wrapped |
trim_trailing_whitespace |
removes spaces at line ends when saving |
insert_final_newline |
adds the final line break when saving, or with false removes it |
end_of_line |
lf, crlf or cr for new lines |
charset |
reported; Ferris IDEA reads and writes UTF-8 |
root = true
[*]indent_style = spaceindent_size = 4insert_final_newline = truetrim_trailing_whitespace = true
[*.{json,yml}]indent_size = 2
[Makefile]indent_style = tabWhen an .editorconfig changes on disk, open editors follow within about two seconds. Properties of
IntelliJ-based IDEs (ij_*) are ignored.
A project’s code style from an IntelliJ-based IDE
Section titled “A project’s code style from an IntelliJ-based IDE”If the project has .idea/codeStyles/ with per-project settings switched on, Ferris IDEA reads
its indentation and right margin, after .editorconfig and before your own settings. It never
writes these files. More about reading such projects:
Coming from another IDE.
On save
Section titled “On save”Settings › Editor › General has two settings for every file you save, both off by default:
Remove trailing spaces on save (not on the caret line) and Ensure every saved file ends with a
line break. An .editorconfig that sets trim_trailing_whitespace or insert_final_newline
decides for its files.
For agents
Section titled “For agents”editorconfig shows which file and which line set each property for a given file, which answers
“why is this indented with tabs?”.
editorconfigEditorConfig properties of a workspace file as the editor applies them: the.editorconfigfiles read (from the file's folder up to one withroot = true), every property with the file and line that set it, the indentation unit, tab width, line break, whether saving trims trailing whitespace and adds or removes the final line break, max_line_length, charset, and values that are not understood.ide_settingsThe user's IDE settings: editor font family, size and line spacing, what saving does (strip trailing spaces, final line break), the terminal shell, Code Style (right margin, indentation per language), Version Control (Update method, force push, protected branches), System Settings (settings.system), Notifications (settings.notifications) and the editor scheme (settings.appearance.editor_scheme), with the file they are kept in;advancedlists the Advanced Settings rows (key, label, description, value, default, modified).set_ide_settingsChange the user's IDE settings, which hold for every project.
No tool matches. Try fewer words, or .