From df838f06175b197a3c8ba3a5bee7f5391e02ef3a Mon Sep 17 00:00:00 2001 From: Jason Yundt Date: Tue, 21 May 2024 09:16:54 -0400 Subject: [PATCH] Create EditorConfig file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Most files in this repo assume that tabs are 8 characters wide and use 2 spaces for indentation. Most people’s editors aren’t configured to do that by default. This can lead to indentation mistakes [1]. The main motivation behind this change is to make indentation mistakes less likely. Many editors [2] will automatically use whatever indentation settings are in the EditorConfig file. On an unrelated note, the EditorConfig that this commit adds includes a tab_width property. This comment in cfile/cfile.h was the inspiration for specifying the tab_width property: // Opens a HOG file. Future calls to cfopen(), etc. will look in this HOG. // Parameters: libname - the path & filename of the HOG file // NOTE: libname must be valid for the entire execution of the program. Therefore, it should either // be a fully-specified path name, or the current directory must not change. // Returns: 0 if error, else library handle that can be used to close the library int cf_OpenLibrary(const char *libname); When tab_width is set to 8, the first “libname” lines up with the second “libname”, and the m in “must” lines up with the b in “be”. When tab_width is set to its default value (4 in this case [3]), the first “libname” doesn’t line up with anything, and the second “libname” lines up with the b in “be”. It just looks more correct when tab_width is set to 8. [1]: [2]: [3]: --- .editorconfig | 21 +++++++++++++++++++++ .gitattributes | 2 ++ 2 files changed, 23 insertions(+) create mode 100644 .editorconfig diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..c7a5f17e --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +root = true + +[*] +indent_style = space +indent_size = 2 +tab_width = 8 +end_of_line = lf +spelling_language = en-US + +[*.md] +# I would use 2 spaces for indentation in Markdown files in order to be +# consistent wit the rest of the project, but the GitHub Flavored Markdown Spec +# requires that you use at least 4 spaces in certain situations: +# +indent_size = 4 + +# This end_of_line override exists in order to be consistent with +# .gitattributes. If you add another override here, then you please also add it +# to .gitattributes. +[{*.vcproj,*.vcxproj}] +end_of_line = crlf diff --git a/.gitattributes b/.gitattributes index 560539ad..aa1783a6 100644 --- a/.gitattributes +++ b/.gitattributes @@ -32,6 +32,8 @@ *.yaml text eol=lf *.yml text eol=lf +# .editorconfig also contains a list of files that should use CRLFs. If you add +# a new “eol=crlf” here, then please also add it to .editorconfig. # Visual Studio project files *.vcproj text eol=crlf *.vcxproj text eol=crlf