.editorconfig
About this file
Settings for text editors, in the EditorConfig format. Many editors read this file, some on their own and some through a plugin, and adjust themselves when you open a file in the repository: which character ends a line, and how far to indent and with what. It changes nothing in the build; it only keeps edits consistent with the existing code.
The C rules match the style that make fmt enforces with .clang-format, and Emacs
users get the same from .dir-locals.el.
Where the settings apply
Lines starting with ; (or #) are comments; this one gives the format’s home
page. root = true tells the editor to stop here: EditorConfig normally also reads
.editorconfig files in every parent directory, and this keeps settings from
outside the xv6 directory from leaking in.
Defaults for every file
A section header in brackets is a file-name pattern; [*] matches every file.
end_of_line = lf: end lines with a single line-feed character, the Unix convention, even on Windows (where editors default to carriage return plus line feed). Tools such asmakeand the shell can trip over stray carriage returns.insert_final_newline = true: make sure the file ends with a newline.indent_style = space,indent_size = 4: indent with spaces, four per level. The sections below override this for particular kinds of file.
Indentation for C, assembly and linker scripts
*.{c,h}: two spaces per level, the xv6 C style you see in every kernel file.*.S: eight, matching assembly files such askernel/entry.S, where instructions and comments are indented by eight spaces and labels start in column 0.*.ld: two, as inkernel/kernel.ld.
The Makefile needs real tabs
make requires each recipe line (the commands under a rule) to start with a tab
character; spaces cause the error “missing separator”. So for Makefile the editor
must insert tabs, displayed eight columns wide. Overriding the space default from
[*] here prevents an editor from silently breaking the build.