I've pushed my code in Ruby to remote Github repository. My code looks completely different now - in Sublime text it was perfectly fomatted, 2 spaces indentation as it should be in Ruby for every logical level. But on Github it's all over the place. What's the reason for it and what can I do to have my code exactly the same as locally?
Asked
Active
Viewed 1,926 times
0
-
1mixed tabs and spaces? how is your sublime set up? – Mladen Jablanović Jul 06 '16 at 13:53
-
I used only spaces, no tabs – Jes Jul 06 '16 at 13:54
-
can you double-check your `translateTabsToSpaces` in Sublime, it should be set to true. – Mladen Jablanović Jul 06 '16 at 13:55
-
Windows, Linux, Mac? On Windows, when you install Git it defaults to switching line endings at a minimum. Don't know if it does any other weirdness. – Charles Jul 06 '16 at 14:00
-
thank you for your advice, I chose Preferences -> Settings - User and I placed "translate_tabs_to_spaces": true inside and saved it. Should it work now on Github after pushing it one more time? – Jes Jul 06 '16 at 14:01
-
https://css-tricks.com/changing-spaces-tabs-sublime-text/ – Mladen Jablanović Jul 06 '16 at 14:02
-
I'm on Ubuntu. I changed it, pushed again but still the same problem. My code looks totally different - if, end were on the same level, now it's in completely different place, while in Sublime it looks perfectly fine – Jes Jul 06 '16 at 14:08
1 Answers
1
I have had this issue before, but, it isn't with GitHub, it is with your code. If you use a tab and tell Sublime show it as 2 spaces it is still passing \t
and not \s\s
in the code.
The real solution is to us spaces \s
instead of tabs \t
, you can easily change a tab to 2 spaces in Sublime, Vim, Text-mate or whatever you want to use. Then the formatting will look the same for everyone and on all platforms.
The Sublime docs for tabs to spaces. https://www.sublimetext.com/docs/2/indentation.html
Also check out this question for more about tabs in Github. How to change tab size on GitHub?
-
Thank you, I'll try, but I've used only spaces - never hit a "tab" button in my code – Jes Jul 07 '16 at 08:01