When I view files on GitHub, tabs appear as 8 spaces.
Example:
Is that possible to change this configuration to 2 or 4 spaces?
If you use tabs to indent your code in your editor and push the code to Github, you might notice that your tab appears as 8 spaces. According to stackoverflow contributors here, you can change the tab size by clicking edit on the file itself and change the indentation configuration.
Tab Size on GitHub. Update: GitHub now has a tab size setting: https://github.blog/changelog/2021-09-21-tab-size-rendering-preference/ By default, in browsers, the tab character takes up 8 spaces in width. This makes tab-indented code hard to read.
You can manage the number of spaces a tab is equal to for your personal account. If you feel that tabbed indentation in code rendered on GitHub takes up too much, or too little space, you can change this in your settings.
You can append ?ts=2
or ?ts=4
to the URL to change the tab-size.
Example: https://github.com/jquery/jquery/blob/main/src/core.js?ts=2
It seems that the value can be anything from 1 to 12. It does not work on Gists or raw file views though.
Source: GitHub Cheat Sheet
When you have a .editorconfig in your repository it will respect it when viewing code on GitHub.
indent_style = tab and indent_size = 4 shows tabs with 4 columns instead of 8 https://github.com/isaacs/github/issues/170#issuecomment-150489692
Example .editorconfig for multiple extensions which works in JetBrains' products:
root = true [*] end_of_line = lf insert_final_newline = true # Matches multiple files with brace expansion notation [*.{js,jsx,html,sass}] charset = utf-8 indent_style = tab indent_size = 4 trim_trailing_whitespace = true [*.md] trim_trailing_whitespace = false
Install Stylus in your browser, than install GitHub: better-sized tabs in code.
There are also Google Chrome extensions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With