code: add .editorconfig
for consistent code style across editors
#22916
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
EditorConfig is a well-known convention to share style settings across different editors. Adding one will make it easier for new contributors or people who like to use a different editor to contribute.
Solved Problem
I've switched from using Visual Studio Code to Neovim because the language server works quite a lot better. Neovim has no way to tell how to indent lines or how to represent tabs. Having this file tells a lot of different editors some basic information like how many spaces a tab represents, whether to indent with spaces or tabs, what the maximum line length should be... It can also tell editors to use a certain encoding, add a newline at the end of files and some other QOL settings.
The developer documentation mentions that a lot of files do not yet follow the style guidelines. This file could help to organically convert more and more files to the correct format as quite a lot of editors are automatically set up correctly.
Solution
.editorconfig
file with shared options for all C/C++ files.Changelog Entry
For release notes:
Alternatives
I think this is the most general approach. It's used by a ton of editors. Sadly Visual Studio Code requires an extension, which could be added to the list of recommended extensions.
Context
I find it weird that nobody has suggested this before. Maybe I'm overlooking something but I can't find a single mention of EditorConfig anywhere in the issues or PRs. Sorry if this has been proposed before.