Free tool · Developer tools
EditorConfig generator
Choose the indent style, line ending and encoding your project uses, and this EditorConfig generator writes a ready .editorconfig. The default choices give a file of 15 lines with 3 sections, and you can copy it or download it with the right file name.
- Free
- No sign-up
- Runs in your browser
9 settingsin 3 sections, 15 lines
- root = true
- space 2
- lf
- utf-8
root = true [*] indent_style = space indent_size = 2 end_of_line = lf charset = utf-8 trim_trailing_whitespace = true insert_final_newline = true [*.md] trim_trailing_whitespace = false [Makefile] indent_style = tab
If your browser drops the leading dot from the file name, rename the file to .editorconfig.
| Section | Property | Value |
|---|---|---|
| * | indent_style | space |
| * | indent_size | 2 |
| * | end_of_line | lf |
| * | charset | utf-8 |
| * | trim_trailing_whitespace | true |
| * | insert_final_newline | true |
| *.md | trim_trailing_whitespace | false |
| Makefile | indent_style | tab |
How to use the EditorConfig Generator
- Pick the settings for indent_style, indent_size, end_of_line, charset and the two whitespace options. Choose Not set to leave a line out.
- Tick the Extra sections you want, or add Your own section with a file pattern and its indent settings.
- Check the preview and the notes under it.
- Press Copy the file, or Download .editorconfig, and save it in the root folder of your project.
What goes into an .editorconfig file?
An .editorconfig file is a plain text file of key and value pairs, grouped under file patterns in square brackets. It sits in your project folder, and editors that support the format read it and apply the settings to every matching file. The file name is all lowercase and starts with a dot. The first line of the default file is root = true, which tells editors to stop looking for more .editorconfig files in parent folders. Then comes a section for [*], which matches every file, with six settings: space indents of 2 columns, LF line endings, UTF-8, trimmed trailing whitespace and a final newline.
Every dropdown on the page lists only values defined by the EditorConfig specification, version 0.17.2, so the file contains no made up keys. A choice of Not set leaves that line out, and an editor then falls back on its own default. For a tab based project the settings change to indent_style = tab, indent_size = tab and a tab_width, for example 4, which gives these lines: indent_style = tab, indent_size = tab, tab_width = 4.
Which properties and values does the spec define?
The core specification defines nine keys: the eight in the table below and spelling_language, which takes a language tag such as en or en-US and which this page leaves out. Key names are not case sensitive. A setting can also be given the value unset, which removes the effect of an earlier setting. The spec does not define a maximum line length key, so this page has no field for one.
| Property | Allowed values | What it does |
|---|---|---|
| indent_style | tab or space | Indent with tab characters or with spaces. |
| indent_size | a whole number, or tab | Columns per indent level. tab uses the tab width. |
| tab_width | a whole number | Columns a tab character stands for. It defaults to the indent size. |
| end_of_line | lf, cr or crlf | The line ending written at the end of each line. |
| charset | latin1, utf-8, utf-8-bom, utf-16be or utf-16le | The character encoding of the file. utf-8-bom is discouraged by the spec. |
| trim_trailing_whitespace | true or false | Remove spaces and tabs before the line ending when saving. |
| insert_final_newline | true or false | End the file with a line ending. |
| root | true or false | Stop the search for more .editorconfig files in parent folders. It sits before the first section. |
How do sections and file patterns work?
Each section header is a pattern. A star matches any text except a slash, two stars match any text including slashes, a question mark matches one character, and [abc] matches one of the listed characters. Braces list alternatives, so [*.{yml,yaml}] matches both file extensions, and {1..3} matches the integers from 1 to 3. A pattern with a slash in it is relative to the folder of the .editorconfig file, and a pattern without one matches at any depth below it.
When more than one section matches a file, the later section wins for any key they share. That is why the default file puts the general [*] section first and the narrow ones after it: [*.md] switches trim_trailing_whitespace to false for Markdown files, and [Makefile] sets tabs. Among several .editorconfig files, the one closest to the edited file is read last and wins. You can add one section of your own, such as [*.go] with tabs of size 8, and the page appends it after the others.
What do the extra sections change?
Markdown is the reason for the first extra section. In CommonMark a line that ends in two or more spaces renders as a line break, so automatic trimming can alter how a document looks. The default file therefore turns trimming off for *.md and keeps it on elsewhere. The Makefile section sets tab indents, a common choice that you can untick, since the page makes no claim about what a build tool requires. The YAML section sets 2 spaces, and the batch file section sets CRLF line endings for *.bat and *.cmd.
After saving the file, check the notes the page prints when a combination is odd, such as indent_size = tab with space indents. To tidy code that the file describes, try the HTML beautifier or the SQL formatter, and compare two versions of a config with the JSON compare tool.
Use it with
- JSON Formatter: format and validate JSON.
- JSON Compare: diff two JSON documents.
- HTML Beautifier: format or minify HTML.
Questions
Where do I put the .editorconfig file?
Save it in the root folder of your project, with the name .editorconfig in lowercase. Editors search from the folder of the file you edit up through its parent folders.
Why did my download lose the leading dot?
Some browsers rename files that start with a dot. Rename the saved file to .editorconfig, with the dot and all lowercase, before you use it.
What does root = true mean?
It stops the search for further .editorconfig files in parent folders. The spec requires it to appear before the first section.
Why is there no max_line_length?
The core spec does not define it, so the page leaves it out and only writes keys the spec names.
Which section wins when two patterns match a file?
The later one in the file, for any key both set. Put general patterns first and specific ones after them.
Is anything I choose sent to a server?
No. The file is written on this page from your choices, and the download is made in your browser.
Sources
The tool's results are computed in your browser by the code on this page, using the sources listed above; the explanations are checked against the tool's own output.