I know it’s a joke but I prefer the tab option. It’s easy to convert tabs to any particular spacing or code point width. It can also vary, if wanted, based on terminal or editor type.
People with worse eyesight can have a wider indentation while those who choose can opt for something more compact
Honestly I always preferred tabs for indentation and spaces for aligning. It doesn’t break anyone’s experience. And if somebody wants two spaces for a two-space-tab-width for indentation and other people prefer four. That will work just fine.
I hate seeing 2 space indents. Unreadable AF ( to me ). At least this way I can easily work in the same codebase without somebody being annoyed ( except for the crying about the tabs )
Why not tabs for both indentation and alignment? (Actually, I see indentation as just a specific use of alignment.) Word processors have been doing it for decades (and typewriters for over a century!). Surely we can convince our code processors to use user-definable, fixed position tabs instead of relative position “tab = x spaces”.
Keeping the [TAB] character in the file then allows everyone the layout they like.
Or has working solo for 40 years fried my brain?
What I mean with tab = x spaces is only visually and not actually ( there will ( obviously) still be a tab character in my preference. Not sure if that was clear.
Because alignment are fixed characters compared to indentation. For indentation the only question is how many characters the next indentation needs to be.
For alignment it is not fixed. As an example of PHP code:
function test(&obj) {
$obj->doSomething()
....->doSomethingElse()
}
The dots would be spaces because in IDEs people generally use a font where every character is equally wide.
If I would tab again instead of spaces it could work out if my tab length display is ( for one or more ) adds up to the width of the variable . If somebody else has a tab width of 2 rather than somebody who has 3. It would only align for one of the two people.
Does make sense? I typed it out after a gym session on my phone.
Additionally. The whole problem is resolved by using spaces for both alignment and indentation. But in the cursor would still jump one space at a time rather than the whole tab ( although there are keyboard shortcuts for jumping words which would jump all of em.
I don’t know. Call me old fashioned. I like what I like :/
I can’t imagine it would be difficult for an IDE to scale the width of spaces found at the start of a line, to emulate this same customization while still preserving my sanity as a fervent space-indenter. I’ve never seen an IDE that does this, but it’d be an interesting compromise.
It’s not difficult at all, and many editors and IDEs already support this, making the entire point moot. Just do whatever the style guide says. I’m into PHP and Python so for me it’s spaces all the way.
How can it tell the difference between spaces used for indentation and spaces used for alignment, if you use the same character for both?
What if instead of having the IDE special case space characters at the start of a line, we had a special character that could represent a variable width space?
Tabs are objectively the better choice as it allows each dev individually to decide tab width in their editors. Spaces in contrast don’t allow this same flexibility as they are used for much more than simply indentation, for example you likely put a space after each argument or operator IE func(arg1, arg2)
or 1 + 2
.
Also, a lot of editors won’t unindent on backspace of spaces indentation, so I end up messing up the indentation with a 3/4 indent
Autoformatter should fix that, unless you use python. (but even then they might fix it to the closest proper indentation level)
Code can be viewed in more than just an editor. It might be in a terminal, rendered in a browser, etc. Sometimes you might even have to view it in an environment you don’t control. I am very disinterested in configuring each and every tool to have sensible tabstops, if such a tool can even be configured.
Then don’t? The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width. You won’t like this but the same exact argument can be made for spaces yet I’d bet you haven’t even once configured the width of those.
I don’t actually change tab width, it’s the default 4 spaces equivalent for me but just because I don’t take advantage of the ability doesn’t mean I should prevent others from doing so.
The whole reason nearly all the spaces guys do 4 spaces is cause that’s the nearly universal tab width.
That is provably wrong. The default tab width in vim is 8 spaces, and the default indentation in yaml is two spaces.
This is simply false, many systems have them configured by default to 8, particularly most CLI tools. Git, for example, is 8, and btw, changing it is not readily done and requires you to hack around it by using a custom pager command. In fact, all core gnu utils (and even bash itself) default to 8, as well vim, emacs, nano, gedit, etc.
I use 2 spaces since I work in Haskell, which is a significant whitespace language where you want certain syntactic constructs to exist at a different level of indentation from your main code block. So yes, I have configured it. 2 spaces is also exceedingly common for HTML (browser Dev tools renders HTML with 2 spaces, even).
There is not a universal indentation width, though it is almost always universal within a particular language or perhaps project, in which case it’s much better to have everything standardized. Code formatters enforced on a project are the norm, and those are way more impactful on how the code is read. But they are valuable because consistency is valuable. And yet, somehow you don’t have huge scores of developers complaining about being forced to format their code in a way they don’t like.
As I said, you don’t necessarily control the environment in which you are viewing code. A common example is reading code over a shared screen. So you can easily end up reading code in a way you don’t like anyway, so it may as well be some reasonable (if not preferable) standard that everyone is using.
Too much waste of space imo, func(arg1,arg2)
or 1+2
is faster to write and to read.
The sole purpose of the tab key is for instructing the editor to insert four spaces.
After years of ass-whopping by python interpreter for stray tab characters, I’m now mentally rejecting the existence of tab character in my computing devices.
Team Tab Supremacy Unite!
Hell yeah tabs