4 ms·
4 spaces? seriously? Why would anyone type out 4 spaces instead of one tab?
by mozumder 10y ago
4 spaces? seriously? Why would anyone type out 4 spaces instead of one tab?
- isbadawi 10y agoYou configure your editor to expand a tab into four spaces.
- ulam2 10y agoPersonally, i use tabs of size four with expandtabs setting. That way i don't have to press four spaces and my files look the same across all editors and platforms.
- Goranek 10y agoI thought everybody does that..who the hell would type space 4 times?
- catnaroek 10y agoA good reason for sticking to monospace characters is that they're always displayed the same, regardless of your personal editor and editor configuration choices. Also, you don't need to type 4 (or however many) spaces directly. Most programming editors can be configured to insert spaces when you press tab, or to replace existing tabs in a file to spaces.
- jdboyd 10y agoVirtually everyone does type one tab and uses a text editor that expands the tab to four spaces in the file.
- jfoster 10y agoYep. I've never really understood why editors tend to replace the tab with spaces, though. It seems to work pretty much the same when indenting, but involves more backspacing and introduces more potential for error (eg. deleting 3 spaces instead of 4) when deleting. What is the advantage that spaces have over tabs?
- BerislavLopac 10y agoThey ensure uniformity regardless of how your editor is set up. E.g. the default vim setting is to display tabs as eight spaces, which means that viewing a file with tabs (or, even worse, a mixture a tabs or spaces) will look differently if viewed on a newly-set server than in my regular IDE (which is set to display a tab as four spaces).
- andkenneth 10y agoAtom at least treats soft tabs as tabs for the most part, when you backspace into a soft tab it will delete all 4 spaces at once.
- partiallypro 10y agoRichard Hendriks? Is that you?
- natrius 10y ago(The last episode of Silicon Valley referenced the tabs vs. spaces debate with exaggerated examples of hitting the space bar four times to indent. This probably isn't a serious question.)
- meeper16 10y agoThere's that balance between readability and being able to operate in highly nested structures and for loops while all kinds of matrix multiplication in AI/ML for example. Minimizing wrapping is important here and you do with 4 spaces, not 8.