Problems with indentations on Github - github

I have some issues with my indentations on GitHub: It shows that I have an indent size of 8 on GitHub even after I changed it to indent size 2 and pushed it.
I have changed the settings on prettier so the code has a indent size 2, and look as it should in my VSCode, but when I commit it is still has a indent size 8.
Attached some photos below and a link to my repo: https://github.com/MT-dotse/project-mongo-api/blob/master/server.js
Code on VSCode:
Code on GitHub:

I do see your code on GitHub with the expected tab size of 2, not 8.
But that is only because I have set my GitHub account setting "Tab Size" to 2.
Which means any tab is displayed (in my GitHub session on a browser page) as 2 spaces, not 8.
As the OP Madelene adds in the comments, as an alternative solution:
I needed to uncheck the "use tabs", and change the tab width to 2 in the prettier extension.

Related

Issue with VSCode vs Github code indentation

I am currently having an issue with the automatic indentation when pushing my code to Github.
I currently have my tab settings to be using spaces on VS Code (tabs set to 2 spaces), yet Github is displaying a massive jump in the organization of the code.
Below are examples of what I am experiencing:
My code looks on VS Code:
My code in Github:
Settings that I have manipulated (tabs to spaces setup on VS Code):
At this point, I don't even know if my settings are set up properly.
You need to set your preferred tab size in github as well.
Go to your Settings (under your icon in the upper right of any repository page),
Appearance/Tab size preferences <== set to 2.
So it is a guthub issue, I think github interprets a tab as 8 spaces by default for some reason.

Github Code displaying wrong indentation issue

I realized that when I push my code to my GitHub repo, the indentation is being displayed as 8..? but In my VSCODE, I have set my indentation as 2.
Is there a permanent fix to this issue? I am aware that I can go into my code and press the pen icon and view my code in 2 spaces, 4 spaces or 8 spaces using the options but this doesn't change my code being displayed in 2 spaces permanently.
Below is the image comparison
Double-check first your GitHub account settings "Tab Size Preference" (new since Sept. 2021)
Those should apply to all of your repositories.

Code pushed or uploaded to GitHub shows extra whitespace

Whenever I push or manually upload code to github extra whitespace will appear in the committed code. I'm using prettier and eslint, I've tried pushing with both enabled and disabled, and with prettier only enabled.
Code as shown on GitHub:
User Settings:
Workspace Settings:
Do you use tabs instead of spaces? Most editors allow you (like you’ve shown) to customize what a tab character shows as (e.g. 8 spaces). My assumption is that your setting is smaller than what GitHub uses for its display. GitHub doesn’t modify your code.
so setting "prettier.useTabs" to false resolves the issue, you would think that the code being pushed and code being displayed would be the same perhaps this is an issue to push to prettier's git repo but i digress, thanks for the feedback.

Change Github online editor tab indent size

I am writing blog using Jekyll on github page.
Instead of using offline editors, I use github online editor which supports markdown very well.
But I when I edit posts, github editor set the default indent size to 8. I tried to change it to 4, but after I save it and reedit this post, github editor reset the indent size to 8.
I am wondering why this happens. How can I set the default indent size to 4 for every file?
Thanks!
It's not a permanent setting. You can change it for the edit mode with the dropdown you mention and for blob mode by appending ?ts=4 to the URL on a per-file basis.
If you're using chrome, you could use Sindre Sorhus' tab-size-on-github extension that does exactly what you want: Force all tabs to represent 4 spaces always.

Github and sublimetext tab spacing

After upgrading to the new iOS and getting a ton of Java exceptions from WebStorm, I've switched to Sublimetext. I've changed my tab settings to 2 spaces (I've tried toggling between both true/false for translate tabs to spaces.
"tab_size": 2,
"translate_tabs_to_spaces": false,
This seems fine in the editor, however now on new files whenever I push to github, it's showing a full tab or 4 spaces. For those that use GitHub/Sublime, any idea how to fix this so github recognizing the tab settings also?
Thank you!
EDIT:
It turns out the following settings in sublime will do as expected:
"tab_size": 2,
"translate_tabs_to_spaces": true,
"detect_indentation" : false
It's not something you can control. Github represents tabs as 4 spaces. The actual file still consist of tabs, so will appear correctly in your text editor (assuming it is configured to 2 spaces per tab).