-1

I have indented my files in my sublime text but when I push to github they don't look indented. How do I fix this? The approach taken to indent file on sublime is: select the code > Edit > Line > Reindent

enter image description here




looks like this on github: enter image description here

Deke
  • 4,451
  • 4
  • 44
  • 65

1 Answers1

1

Your issue looks to be caused by your use of literal tab characters for indenting as opposed to using spaces instead.

If there's a hotter holy war topic among developers than the debate of tabs versus spaces, it's probably related to how wide you should interpret a tab character to be for display purposes if you happen to use them.

In particular your images would appear to indicate that you think that tabs should be 2 characters wide and GitHub thinks they should be 8. As mentioned in this answer you can append an extra query field to the URL in GitHub in order to view the files the way you prefer them to be viewed.

As far as I'm aware that just changes how they're rendered on the page when you view and doesn't actually modify the file at all. If it's important that the file retain the same indent levels regardless of where or how you view the file, you should convert from tab indentation to space indentation instead since a space is unambiguously sized.

If you're using Sublime Text you can do that by clicking in the status bar where it says Tab Size: 2 and select Convert indentation to spaces; the status bar will switch to say Spaces: 2 to indicate that the indent has changed.

OdatNurd
  • 21,371
  • 3
  • 50
  • 68