Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.editorconfig file in GitHub

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.

like image 730
Zepee Avatar asked Nov 24 '15 11:11

Zepee


1 Answers

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.

like image 107
Trey Hunner Avatar answered Oct 15 '22 14:10

Trey Hunner