Indentations are always 8-space T A B S

> Tabs are 8 characters, and thus indentations are also 8 characters. There are heretic movements that try to make indentations 4 (or even 2!) characters deep, and that is akin to trying to define the value of PI to be 3.

Who the fuck indents with two spaces? What kind of scum force their shitty two-space indentations on others by not just using tabs? I'd wager it's the IDE fags. Fuck you.

Other urls found in this thread:

kernel.org/doc/html/v4.10/process/coding-style.html#indentation
kernel.org/doc/html/v4.10/process/coding-style.html
google.github.io/styleguide/
twitter.com/SFWRedditImages

default indentation by the ide, either 2 or 4. you can't be serious, taking up that much space for what?

The chad 4 space indent
The virgin tab

Because more than three nested control flow constructs in the same function is pure cancer. Sometimes you just need to refactor your complex functions into smaller, more digestible subroutines. Nice, long indentations make your code easier to read (more "breathing room") and they let you know when your logic is too nested.

Also the thing where anyone can set the tab width however they like if tabs are used as indentation.

The default tab length in Nano is 8 spaces. And since Nano is the only editor worth using, the correct indention length should always be 8 spaces.

ed is the standard text editor.

kernel.org/doc/html/v4.10/process/coding-style.html#indentation

Also the only relevant C-like-language style guide:
kernel.org/doc/html/v4.10/process/coding-style.html

As the above alludes to, GNU's C style guide is an abomination. (Does anyone disagree on this? I honestly don't think so)

>ide

>anyone can set the tab width however they like
not strictly true, because there are some occasions where you need either 1 or 2 tabs to get things to the same column
but of course it's gonna look wrong if you override the tab width to something wrong

I just found out about folds

I say just be in the habit of not doing that. For example, it you have lots of arguments to a function, just indent once for the following parameters:
// not actually that many arguments, but you get the idea
my_type my_function(size_t first_argument,
struct my_struct* second_argument,
void* third_argument)
{
...
}

If you're lining up something like array elements, indent once, and then use spaces as needed:
static const int my_array[16] = {
0, 1, 2, 3, 4, 5, 6, 7,
8, 9, 10, 11, 12, 13, 14, 15
};

I wasn't talking about that, I was referring to this kind of situation, which I find comes up quite often
it'll look wrong if you change the tab width

I think the advice still applies there. I'm also of the opinion that lining up struct members like you're doing there is a not-so-great thing to be doing, though it's not unreasonable.

Either way, have at it with spaces in that context. Use (8-space, preferably) tabs to indent your code in nested control flow constructs, use spaces *between* tokens in all contexts (for exactly the reason that you mention; they're not consistent across different people's editors).

thats because you're supposed to indent with tabs and align with spaces you mong

Python uses whitespace to group blocks of code instead of braces

>use the wrong tab width
>expect my code to look right
neither my fault nor my problem

what are you talking about
two is amazing

8-character indentation is too much.
I'm more concerned with people using pig disgusting cuddled else statements

>Now, some people will claim that having 8-character indentations makes the code move too far to the right, and makes it hard to read on a 80-character terminal screen. The answer to that is that if you need more than 3 levels of indentation, you’re screwed anyway, and should fix your program.

Okay? This strikes me as nothing more than a "fun fact"; was it supposed to be an argument?

Look. I know the Python community has PEP8 so it's acceptable to use 4-space indentations for Python code. Either way, the interpreter (in Python3) only yells at you if you mix tabs and spaces; you can use tabs in Python code.

Not an argument, OP asked who indents with two spaces.
Also:
1) relying on whitespace to separate blocks is terrible
2) tabs and spaces may be freely mixed in python 2, which is still extremely widespread

JavaScript usually uses two spaces because things get super nested.

Hard tab has no defined width and can be adjusted in an editor. There are only two sane ways to indent: all spaces or smart tabbing. With smart tabbing, you make zero assumptions about the width of a tab except for the fact that it is as wide as any other tab. Therefore, indentation is performed with tabs, and alignment with spaces. Further two lines may be considered aligned only if they contain the same number of leading tabs.

What kind of autismo actually gives a shit about aligning their code into pretty little columns?
>change a variable name
>WHOOPS LOOKS LIKE I HAVE TO REALIGN ALL THIS CODE
In sum, unless you're using Lisp, the One True Indentation is tabs and not aligning anything otherwise.

That sounds about right.

And thus smart tabbing is the one true way to indent. To indent with spaces at your own preferred width, while consistent, is a crime against your peers.

>mixing tabs and spaces
haha no
next

You know unless that quote is from rms nobody on Sup Forums will even care

It's from Linus. Stallman's got a one-track mind for free software, a lot of us care a care more about just code itself; kinda like Torvalds.

if you have lots of arguments to a function, you probably need a fucking struct.

...

>making a vector of shared pointers of subclasses of a pure virtual class just so you can print some emojis and /r/ns to the screen

python kek

I like 3 space tabs. 2 is too narrow and 4 is fat

I do it just so autists like you can't overindent my code.

holy shit nobody cares, if you're working on someone elses project learn to adapt to their style. make your own damn project if you hate it so much

Indent != alignment, autist.

spbp

>>Who the fuck indents with two spaces?
a team of highly educated autists at Google appear to think 2 spaces is the answer in pretty much every language: google.github.io/styleguide/
I think Go bucks the trend though.

void
correct_indentation()
{
// 1 tab
}

I put my tab size as 2 spaces, then I use tab.

tabs indent, spaces align

now it doesn't matter how wide your tabs are. Let me configure my editor how I like, and you can configure it how you like.

>function name on newline
nah

>not using the patrician choice of formatting multiple argumets
int foo (
struct struct_t x,
struct struct_t y,
struct struct_t z
) {
// ...
}


Also if you typedef a struct you should unironically think of kys

cuckthon 3 lel

>forget a space
>lmao all code is now broken
tell me how replacing {} with indentation is a good choice?

curly braces are aids
at least use IF/ENDIF

>Also if you typedef a struct you should unironically think of kys
why

This is correct.
8 spaces is for psueds that want to be Linus
2 spaces is for webdev brainlets

indentation 1 space
it's false .. 2 or more space no benefit at all to readability.

>1 space
you disgust so many layers of mine that you could write a protocol out of it

>2018
>still not using 3.14 space indentation
Pleb.

Who the fuck cares, you fucking code monkey.

for me, it is 32 space indentations. if you think this is too much, then you need to fix your code.
for (var i = 1; i

Tabs are 4 characters not 8 you tasteless shitter.

You're retarded and didn't understand what he said.

Please, you obviously need to rework your program flow. If 48-space tabs are too wide for you, then your program logic is broken anyway. Fucking plebs trying to shorten it to 32 (or even 8!) spaces are obviously cancer

I understood perfectly

>1) relying on whitespace to separate blocks is terrible
I can't event count how many times, while editing code 5 or more indentations in, I lost a closing parentheses or a bracket. Yes, it's terrible code. And without a compiler it's not that easy to find them (Javascript)
>2) tabs and spaces may be freely mixed in python 2, which is still extremely widespread
You can disable the specified warning, as I do. Or just let your ide/editor fix it automatically.

But function calls

curly braces have curves, they're the waifu of coding. Why would you want to throw them out

Who cares what it is? You can configure it in your editor to whatever you like. Furthermore, if people correctly use tabs to indent and spaces to align, it will be properly formatted no matter what you set it to.

Why not? You can freely change the indentation width without fucking up the alignment. What's the downside?

You very obviously didn't. Or, you don't understand what "mixing tabs and spaces" means. Either way, you don't know how to format code

Tabs and spaces are used to different purposes here. If you do not feel your co-workers smart enough to follow a schema that clearly differentiates between indentation and alignment, the next best (and indeed only other acceptable) option is to use spaces for everything.

Tabs should never be used for the role of alignment, whether or not they are used for indentation.

. while(condition){
foo++;
bar--;
}

Center aligned, of course

>using mla format

it's ok until you get 3 tabs out in multiple if statements and your code no longer fits on the screen.

> Tabs are 8 characters

Bull to the shit. A tab's length is completely arbitrary. It was always arbitrary, even when it was first used, on typewriters.
For computers, the software decides on how to react to tab, it definitely isn't 8 characters by any standard or norm.

you should not align code if you are using tabs, a mix of tabs and spaces is a shitfest that breaks the only purpose of actually using tabs in the first place

How many characters per line is acceptable for programming?

the CHAD brace styling

80. 160 if it's a verbose language.
Readability is King though

I'm wondering if your comment goes nearly to "uhm... 2 spaces... more readable code".

You can hit the 80-char limit with like 3 arguments with slightly long type names.
I wouldn't bother with a struct until you have like 7 or 8 arguments. It just makes your function a pain the ass to use otherwise.

...

Some men just want to watch the world burn.

Anything more than a single space is wasteful.