The EditorConfig standard is an alternative to the .dir-locals.el files, which can control only a very small number of variables, but has the advantage of being editor-neutral, not specific to Emacs. Those settings are stored in files named .editorconfig, and affect the files in that directory and its subdirectories.
If you want Emacs to obey the settings from .editorconfig files,
you need to enable the editorconfig-mode
global minor mode. This
is usually all that is needed: when the mode is activated, whenever a
file is visited, Emacs will look for .editorconfig in the file’s
directory and its parent directories, just as it does for
.dir-locals.el. When both .editorconfig and
.dir-locals.el files are found, their settings are combined, and
in case of a conflict, the setting coming from the file closest in the
directory hierarchy takes precedence. If they are equally close,
.dir-locals.el takes precedence. In terms of security, the
.editorconfig settings are subject to the same checks as those
coming from .dir-locals.el and from file-local variables (and
also honor enable-local-variables
). See Safety of File Variables.
The indent_size
setting of the EditorConfig standard does not
correspond to a fixed variable in Emacs, but instead needs to set
different variables depending on the major mode. Ideally all major
modes should set the corresponding editorconfig-indent-size-vars
,
but if you use a major mode in which indent_size
does not take
effect because the major mode does not yet support it, you can customize
the editorconfig-indentation-alist
variable to tell Emacs which
variables need to be set in that major mode.
Similarly, there are several different ways to trim whitespace at
the end of lines. When the EditorConfig trim_trailing_whitespace
setting is used, by default editorconfig-mode
simply calls
delete-trailing-whitespace
(see Useless Whitespace) every
time you save your file. If you prefer some other behavior, you can
customize editorconfig-trim-whitespaces-mode
to the minor mode of
your preference, such as ws-butler-mode
.