Github and sublimetext tab spacing - github

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).

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.

Problems with indentations on 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.

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.

Convert 2 spaces to tabs in Visual Studio Code

I was editing a project, as I have been for months, and randomly only one of my files converted all of its tabs into two spaces. I use "4 spaces" for my tabs, now this one single file decided to become 2 spaces. How can I fix this and convert this file back to 4 spaces? It is only affecting this file, all other files still use 4 spaces.
This thing is just buggy. It is now back to 4 spaces and I have no idea why.
Try going to settings (CTRL+, or CMD+, on Mac) and search for 'detect indentation'.
Play around with that setting as well as with the Tab Size setting. When you're done, go to your file, select all content (CTRL+A or CMD+A on Mac), unindent everything (SHIFT+TAB), then open the command pallete and search for 'Reindent'.
Click the 'Reindent Lines' option and see where it gets you.
Also, check if you have a .vscode folder in your project. It may contain settings that override your global vscode settings.

Visual Studio Code settings ignore project files

I've noticed that in my project, my project files don't adhere to the settings. EG tab == 4 spaces. Tabs are only adding 2 spaces. The settings file does it properly. It uses 4 spaces with I hit tab. Do I need to add something to include the project files? I've tried adding this to my user settings. I also added this to the workspace settings but it still didn't seem to work.
"editor.insertSpaces": false,
"editor.tabSize": 4,
and tried using true as well. It just doesn't do it. The project files seem to be ignored. Is there some place I can fix this?
You need to also set "editor.detectIndentation": false,, otherwise the program auto-detects the indentation based on the open file. Documentation has default file that should help with any other settings.