Okay, just curious again: How many spaces do you indent? I indent 4 spaces. I think 4 will be the majority.
Printable View
Okay, just curious again: How many spaces do you indent? I indent 4 spaces. I think 4 will be the majority.
Tab.
never tab unless you have tabs set to insert spaces.
Well, how much does the tab indent in your editor?
You know, I agree. Tabs can really mess up your indentation. But everyone seems to use them.Quote:
never tab unless you have tabs set to insert spaces.
I let Dev-C++ indent for me, unless an if statement indents too far, then I set it to about 7. Otherwise, it's 4 or 5. So I selected all three options above. :p
If you can manage not to mix the two, tabs are fine. 2 or 3 spaces are not enough. Use 4 or more.Quote:
never tab unless you have tabs set to insert spaces.
You guys are weird. I ALWAYS indent 4 spaces.
My experience doesn't justify this statement. In my opinion, 1 is too little, but 2 is enough if the code is formatted consistently. 4 can easily be too much with some styles of C and most styles of C++ where lines can get pretty long, and the indention doesn't help.Quote:
2 or 3 spaces are not enough. Use 4 or more.
Does anyone actually indent 1 space?
I know Govtcheez voted for everything, but I doubt he uses 1 space. Well, maybe.
I do a tab, whyd does a tab screw things up?
Well, if you transfer it, it sometimes ends up looking like this:
Code:int main(void) {
if(1) {
printf("hi");
}
return 0;
}
Yup. I use 2. 4 is too much; especially if you have to keep it under 80 char per line, those indents add up quickly.
If they "add up quickly", modularize your program (ie, break it up into functions). One of my books suggests that you shouldn't go over three levels of indentation, but I don't go that far.
But I think 8 is too much, for all that.
If your lines are too long it's not the tab size that is the problem.
Yea, that would be the fault of a stupidly verbose standard library. ;)Quote:
If your lines are too long it's not the tab size that is the problem.
voted everything
When you tab in Dev-C++, it puts multipule spaces according to the line above or below the line you are tabing. (I tab.)
I use tab, with any modern editor you can setup so much tab stuff it allows one to have their own spacing style.
NamespaceQuote:
Originally Posted by dwks
>> Class
>>>> Function
So you can only have one level deep if statements and loops. No if's in a loop or loops in an if, or a single nested if.
No one can really set a hard and fast rule like that. I always set the IDE to replace tabs with 4 spaces though. Using plain tabs makes a huge mess if someone else used spaces - if the tab size is set to 4 it might look ok, but if it's say 8, things get very ugly.
Good in theory, but I find that it is not always practical.Quote:
Originally Posted by dwks
I use three. I find two to be too little (that was a fun sentence), and more than four excessively obnoxious. Between three and four, I prefer three.
I voted 4 and 8 spaces. It all depends what platform I'm working on (either solo or in a team).
When writing for Windows I usually stick to the 4 space standard, and 8 for Linux.
Stop using the Kernel style then, Allman all the way! ;)Quote:
Originally Posted by dwks
Also, don't mix spaces with tabs. Use one or the other, not both.
I use 3 or 4, whatever is standard in VC2003.
Coding standards at your house will decide. Left to me 4 spaces.
8 space tabs all the way. Indentation is meant to make the code more readable, and IMO 4 spaces just isn't enough.
I also prefer tabs over spaces since it consumes less space (not a big issue though), and it lets whoever is working on my code display it how they like without having to re-indent the whole file.
Here's a tip for you VIM users who can't paste properly.
Code::set paste
Thanks for the VIM tip, I can never get it to past right :)Quote:
Originally Posted by ^xor
2 for C and C++ and Perl and Java and HTML, 4 for Visual Basic. hehe.
Three spaces for me also. I tried two in another programming language I use, but never could get used to it, so I switched back to three.Quote:
Originally Posted by Zach L.
4 spaces, though with a tab.
I find using an odd number of spaces odd, for some reason.
4. Just typing this
I use a varying number of spaces depending on the language I'm working with...php my spacing is very sporadic because my editor replaces all tabs with spaces automatically so it's hard to have some uniform spacing thing going on (as the auto-tab-indentation-selector-thing isn't very good, it'll randomly indent 2 spaces, or maybe 4, or maybe 7).
C++, however, I use 4 all the time, just seems like a decent in-between as I don't think 2 would make the code incredibly readable but 6 or 8 would make the code harder to read. In the end, I doubt I'll run out of hard drive space by using 4 spaces to indent as opposed to 2 or 1, heh, these days you can buy a gig of hard drive space for $1.
I start at left margin and add 2 per level of indentation.
I've never needed to go deeper than 6 that way.
I use tabs where each tab is 5 spaces. Never noticed the problem like drks posted example.
I use 4 spaces. In Code:Blocks a Tab is 4 spaces so I use that too. ;)