9 ms·
The reason I use tabs is pretty simple. It's faster to move around only using the keyboard. It's also faster if I'm changing code that requires reformatting.
by redm 9y ago
The reason I use tabs is pretty simple. It's faster to move around only using the keyboard. It's also faster if I'm changing code that requires reformatting. Finally, when another developer looks at the code, their IDE will render the tabs as whatever its set up for, 2 spaces, 4 spaces, etc. In other words, it adds flexibility.
Brace yourself: I use two spaces after the end of sentences too. [1] I am quite the rebel.
Modern IDE's (Sublime Text) let you easily convert spaces to tabs (or vice versa) and intention length of existing code.
[2]
[1] http://www.slate.com/articles/technology/technology/2011/01/space_invaders.html http://www.slate.com/articles/technology/technology/2011/01/...
[2] https://css-tricks.com/changing-spaces-tabs-sublime-text/ https://css-tricks.com/changing-spaces-tabs-sublime-text/
- tomsmeding 9y agoDon Knuth seems to agree with you a bit; TeX automatically inserts some extra spacing between the end of a sentence and the beginning of the next one. You don't have to type it yourself though!
- zelos 9y agoThat's why most people stopped inserting the extra spaces themselves, instead allowing the layout engine/word processor etc to do it for them.
- saalweachter 9y agoThen your editor / layout engine has to be smart enough to distinguish between Dr. Smith and the end of a sentence.
- jinglebells 9y ago> Finally, when another developer looks at the code, their IDE will render the tabs as whatever its set up for, 2 spaces, 4 spaces, etc. In other words, it adds flexibility. This is exactly why I use tabs and the reason which appears to never get cited in the holy wars. People who use spaces want to line up their '=' signs, that's fine, but I don't believe it's my position to enforce the amount of whitespace another developer has to use in their editor. It's an accessibility thing, they might have their font size really large because of eyesight problems in which case 8 spaces is going to make reading the code a lot harder. The fact that Python's rule used to be 8 spaces, then got changed to 4 thereby invalidating old code really showed me how shortsighted it is to use a set number of spaces in a whitespace sensitive language.
- hollander 9y ago> People who use spaces want to line up their '=' signs How does that prevent the use of tabs? You can use tabs to indent, and spaces for your = signs.
- ElijahLynn 9y agoMixing tabs and spaces is a nightmare, unless it is your personal non-open project. If a project is open or shared with anyone you need a simple rule to follow. There shouldn't be another leaf in the decision tree for when to use tabs or spaces. We have enough decisions to make the way it is.
- IanCal 9y agoFirst, my golden rule is "do whatever the other devs using the repo do" but > People who use spaces want to line up their '=' signs, that's fine To me this feels like it's a good use of spaces as well as tabs. Tabs for indentation, to get your nesting right. Spaces to align things. That way setting your tabs to X spaces works just fine and everything remains nicely aligned. Though I'm not sure how common this is, so I just use spaces.
- jdmichal 9y agoGet your blasphemous mixing of spaces and tabs out of this holy war!
- pyre 9y ago> The fact that Python's rule used to be 8 spaces, then got changed to 4 thereby invalidating old code really showed me how shortsighted it is to use a set number of spaces in a whitespace sensitive language. Not sure what you're talking about here. In Python, as long as the indentation is consistent you could (e.g.) use 2-space indentation to make a code block. It's considered bad practice, and most linters will complain about it since 4-space indentation is the "golden rule." If you're talking about the Python interpreter's interpretation of the tab character in indentation, that's different[1]. In any case, old code that has 8-space indentation using spaces rather than tabs is still good. The only issue would be old code that mixed tabs and spaces for indentation, which might not match up anymore to make correct code blocks. But, in general, it's just a bad idea to mix tabs and spaces for indentation. [1] To the uninitiated, the Python interpreter treats a tab as X number of spaces when parsing the source code. This means that technically you could mix a block's indentation between tabs and a corresponding number of spaces. For example, if X = 4, then this code block would work: def function(): <tab>something() something_else()
- tomsmeding 9y agoDon Knuth seems to agree with you a bit; TeX automatically inserts some extra spacing between the end of a sentence and the beginning of the next one. (But the extra space is less than one full inter-word space.) You don't have to type it yourself though!
- rlpb 9y ago> when another developer looks at the code, their IDE will render the tabs as whatever its set up for, 2 spaces, 4 spaces, etc. This is an argument I hear often from tab proponents. What it misses out is the downside: my IDE has a certain arrangement on my screen, and I'll either have to invoke horizontal scrolling or I'll have a bunch of wasted space if you are using different size tabs from me. This is far from flexible. There's also the (more minor) issue that you then can't line things up on a line below at an arbitrary place if the indentation of the two lines is to be different. This is admittedly less of an issue, but it does arise on the occasion one wants to structure text, for example in a table in a comment block. I've come to the conclusion that the only sensible tab width is 8, since that works everywhere including in tools where it isn't practical to set (eg. less). Further, the only sensible screen width is 80 characters, since that also works everywhere. But I'm not writing this to get into a holy war; only to point out that the "it adds flexibility" in your argument is a fallacy.
- jordanlev 9y ago> if you are using different size tabs from me. But the point of tabs is that you tell your editor how many spaces wide you want them to be, so unless I'm misunderstanding you, this is not an issue. As for lining things up, tabs are used for the indentation level of the current line, but if you need to further nudge things within that line then you'd of course use spaces (after the initial tab indent).
- rlpb 9y agoYou misunderstand me. I can set my tab size different from yours, but doing that will change the horizontal window width required to view your code. This is the problem I'm describing.
- jordanlev 9y agoHow is that problematic though? I'm not aware of any language or situation where the width of the window has any impact on anything.
- 9y ago
- rubber_duck 9y agoIf you're looking for efficiency for text navigation/editing you should consider learning vim/using vim mode in your editor.
- vanjoe 9y agoRubber duck is trying to lead you astray. Use emacs!
- jasonkostempski 9y agoEvery editor made for coding supports moving through whitespace with a single command.
- NegativeK 9y agoThis is extended to all text editing -- use ctrl to modify your movement (arrows, backspace, delete) to word boundaries.
- fredsir 9y agoProblem is that moving from and to the arrow keys to navigate is an anti-pattern that is not present in at least vim where you can stay on home row at all times, which is why I dread having to write in editors that don't support a vim mode.
- paradygm 9y agoYou are among friends, in your use of tabs and two-spacing at the end of sentences. There aren't many of us, and seemingly fewer every day, but we are a force.
- MikkoFinell 9y agoYou think you are doing others a favor by using tabs, but in fact you are creating a hassle instead. When I open your tabbed code the first thing I have to do is run it through some script that replaces all tabs with spaces, so that the files will be formatted the same way as the rest of the code base.
- dTal 9y agoSome script? You mean the built in Unix utility 'expand'? Supposing I submitted code indented with spaces, but the wrong number. Would making the formatting match be easier, or harder? Maybe you should just use tabs in your codebase.
- MikkoFinell 9y agoMaybe you should use the right number of spaces in your codebase.
- dTal 9y agoBut what's the "right number"? Space enthusiasts can't agree. Tabbers know how many tabs to use: one, per indent.
- chucksmash 9y agoTo me, moving around faster using only the keyboard is an editor feature. My experience is with emacs but to go from the left margin to the first non-whitespace character across a vast swath of spaces in auto indent mode, I just press <tab> once. I'm sure other editors have something similar. If you're iterating over the whitespace manually you are doing it the slow way :).
- dghf 9y ago> The reason I use tabs is pretty simple. It's faster to move around only using the keyboard. Well, yes, if you use the arrow keys (unmodded) and nothing else. But who does that? Even Notepad lets you jump from word to word with CTRL-left/CTRL-right. Sublime Text must have something similar, surely?
- patrickking 9y agoOn OSX, in Sublime Text: - CMD with arrow keys moves to line ends - Alt with arrow keys moves between words - Ctrl, under some circumstances, lets you operate on parts of a camelCased or snake_cased word (with backspace and with shift + arrow keys, but not with arrow keys all by themselves) It's the best setup for moving around code that I've encountered.
- fredsir 9y agoI like vims better to be honest. More granularity, and I can stay on home row instead of moving my hand to and from the arrow keys.
- sbov 9y agoBeyond that, this tends to work across all input fields in your OS. If you're missing this you're missing out on being more efficient in any typing based activity.
- vanderZwan 9y agoYou think you're a rebel? I have my tabs set to three spaces.
- Kequc 9y agoYou must be stopped!
- saghm 9y ago> Brace yourself: I use two spaces after the end of sentences too. [1] I am quite the rebel. The paragraph above this one seems to use single spaces after periods. Is this a Hacker News formatting thing, or are you conning me?
- johnfn 9y ago> I use two spaces after the end of sentences too. [1] I am quite the rebel. Why don't you just use a tab character?
- chrisan 9y ago> It's faster to move around only using the keyboard. There are faster ways, at least with JetBrains products, to navigate code that doesn't involve arrowing through spaces/tabs The only reason I use spaces is the formatting is the same everywhere without messing with settings. > Brace yourself: I use two spaces after the end of sentences too. Me too! I was brought up this way. If you want to get into really sick and demented old habbits, my wife indents the first sentence of each paragrah... in emails lol