I'm trying to add an .editorconfig to our github repo to make the github code viewer display tabs as 4 spaces. This sounded pretty simple and GitHUb supposedly offers native support for it, however I can't get it to work.
I've added the following .editorconfig to the root of our repo:
# top-most EditorConfig file
root = true
# 4 space indentation
[*.{cpp,h,cs,xaml,editorconfig}]
indent_style = space
indent_size = 4
# # #
# # #
Those last 2 lines with hashes are done with tabs and spaces respectively. When I open this file in the github code viewer, the first line shows with tabs as 8 spaces. If I add ?ts=4 to the URL the tabs do display as 4 spaces.
Am I just using this wrong/expecting it to do something it doesn't? Our issue is older code in the repo was added with tabs, and we wanted to start using tabs as spaces (4 spaces) in new code, so we wanted the existing tabs to display aligned with the new ones.
Any guidance would be appreciated.
GitHub does in fact support EditorConfig, though I'm not sure they've ever officially announced this. They wrote the Ruby core library for EditorConfig.
As for your issue, it may be a bug in the GitHub support. The in-browser text editor used on GitHub is limited in a number of ways that makes EditorConfig support tricky. I can't remember whether this specific issue was a problem though.
There is a web browser extension that adds more complete EditorConfig support. You might want to use that extension and see if it works. If so, an issue should be submitted to GitHub with instructions for reproducing the problem.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With