Configure your browser’s default tab size

I always used space for indentation. But lately I got convinced that tabs are better. So I switched to it for my new projects, enforced by Editor Config and Prettier.

My preference is one tab equals two spaces. But by default my browser’s (Firefox) de…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by drazik

I always used space for indentation. But lately I got convinced that tabs are better. So I switched to it for my new projects, enforced by Editor Config and Prettier.

My preference is one tab equals two spaces. But by default my browser's (Firefox) default tab size is 8. So I wanted to tweak it.

Unfortunately, I couldn't find a setting related to it. But I found the CSS tab-size property. This property existence and good browsers compatibility means that if I can apply tab-size: 2; by default on all pages I visit, my preference will by applied.

To do that, I downloaded the Stylus extension and created a custom stylesheet with the following CSS code:

body {
  tab-size: 2;
}

And voilà 🎉. Now I simply author my source code with tabs, my editor is configured to respect my preference for tab size and my browser also respects it. And every person that reads my code can also just set their tab size to their preferred value without me proclaiming "your should read it this way".

PS: please don't fight between spaces and tabs here. This post is not intended to elaborate on this question, but to help people looking for ways to configure their browser's default tab size.


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by drazik


Print Share Comment Cite Upload Translate Updates
APA

drazik | Sciencx (2022-09-22T21:29:04+00:00) Configure your browser’s default tab size. Retrieved from https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/

MLA
" » Configure your browser’s default tab size." drazik | Sciencx - Thursday September 22, 2022, https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/
HARVARD
drazik | Sciencx Thursday September 22, 2022 » Configure your browser’s default tab size., viewed ,<https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/>
VANCOUVER
drazik | Sciencx - » Configure your browser’s default tab size. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/
CHICAGO
" » Configure your browser’s default tab size." drazik | Sciencx - Accessed . https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/
IEEE
" » Configure your browser’s default tab size." drazik | Sciencx [Online]. Available: https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/. [Accessed: ]
rf:citation
» Configure your browser’s default tab size | drazik | Sciencx | https://www.scien.cx/2022/09/22/configure-your-browsers-default-tab-size/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.