Reputation: 396
When creating a Gist on Github there is a setting for indentation (tabs or spaces; size 2, 4, or 8). After setting indents to tabs size 4, it changes to tabs size 8 after I save it. Editing it afterwords doesn't do anything. Other settings don't produce the expected result either. Am I misunderstanding this feature somehow? Can't find any documentation regarding this.
Upvotes: 27
Views: 1450
Reputation: 21926
While creating the gist, that setting is indeed broken. Github says this is by design, LOL.
Luckily, there’s another setting in the account preferences, which does work. That setting is “Tab size preference” on the following page: https://github.com/settings/appearance
The default value is 8. The setting applies globally, and it also affects the gists you view while logged in.
Upvotes: 1
Reputation: 3430
Convert the indentation from Tabs to Spaces or Spaces to Tabs by using vscode with the easy and simple following steps.
Upvotes: 0
Reputation: 1528
I replaced tabs with four spaces in Notepad++ (Ctrl+H), and it works. You can use any numbers of spaces.
Those tabs are automatically displayed as a 8-character-tab in Github Gist.
Upvotes: 1
Reputation: 74
This is happening because while writing the code, you used the tab key which inserted 8 spaces. Here's a solution that I use.
Copy all your code to a local file and open it in the vi editor.
cat>temp.js
ctrl+shift+v
to paste and ctrl+d
to save.
vim temp.js
(Or change the extension as per your file.)
Run the following command that I found from here. This will half the existing space.
:%s;^\(\s\+\);\=repeat(' ', len(submatch(0))/2);g
Press the esc
key then :x
and enter
key to save and exit vi.
Copy the code in your temp.js file and paste it in your gist with spaces as 4.
Upvotes: 0