Change Github online editor tab indent size - github

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.

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.

How to open markdown preview by default to the bottom?

By default, the markdown preview in VS Code opens on the Side. I do this action quite a bit and I always have to drag a drop it to the bottom of the current tab.
I looked in my settings to see if there was a way to change this default behavior and didn't see anything that looks like it would change it.
Any suggestions on how to change this default setting?
You can try to use one of the extensions that allow to execute multiple commands and do:
markdown.showPreviewToSide
workbench.action.toggleEditorGroupLayout

Is it possible to seperate tab and indentation configuration in Visual Studio Code?

I'm trying to configure Visual Studio Code to treat tab characters in files as being 8 spaces but have indentation (when I hit tab on the keyboard) as being 4 spaces. Is this at all possible?
I can achieve this in eclipse with the code style formatter but can't achieve the same thing in VS Code.
(I've submitted an issue to the VS Code repository on git hub now https://github.com/Microsoft/vscode/issues/42643)
You need to modify your user settings (or workspace settings) in VS Code. By default, it is set a tab as 4 spaces.
You can modify the setting "editor.tabSize": 4, and set that to 8.
However, also be aware that "editor.detectIndentation": true, is set to try by default and this causes VS Code to detect the indication size of the file you open. So if the file itself has spacing set to say 4 or even 2, then VS Code will auto set spaces to that value while that file is open...or until you convert indentation.
You can convert indentation via the command palette and that should update the spacing to your desired setting.
As far as I've seen, No.
It appears that VS code still can't separate the two concepts of tab size and indentation distance. Some suggestions, ideas and hopeful soulmates of ours can be found in this issue on github: https://github.com/Microsoft/vscode/issues/5394#issuecomment-215414643
I agree with the comments in that issue in that separating the tab size from the indentation distance is a nice feature that solves several problems. The only thing needed is for someone to actually do the work to implement that in vs code.
Or, a less intrusive route, I have actually been thinking about creating an extension to override the indentation action in some way and use a custom settings variable for the indentation distance there... but I have yet to learn enough about the internals of VS code to determine if that's even possible for an extension to do.