The One True Style of indentation

One space
0% (0 votes)
Two spaces
7% (1 vote)
Three spaces
0% (0 votes)
Four spaces
27% (4 votes)
Six spaces
0% (0 votes)
Eight spaces
0% (0 votes)
Tabs
67% (10 votes)
However I feel today
0% (0 votes)
Random
0% (0 votes)
All on one mighty big line
0% (0 votes)
Total votes: 15

- wil

He has: 296 posts

Joined: May 2002

Oh wow! I love being the only one who does 2 spaces... It's just easier to do 2 spaces than 4 or a tab. And I use Notepad, so the tab is WAY to big. But I also double-enter blocks of code. Which makes it way easier to read.

[James Logsdon]

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

I hate the way notepad has a tab width of 8 columns. Code with a lot of nested items can get pushed pretty far to the right.

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I learned how to write rudimentary perl first, then JavaScript, and now I'm playing with PHP. Somewhere along the line I read that article and also the articles about where braces should go (in different languages) and I'm hopelessly addicted to using spaces instead of tabs (which is why I have the program set to replace tabs with spaces) -- if you go into another editor where the tab is set differently, you have a devil of a time with the code.

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

very good doc

They have: 601 posts

Joined: Nov 2001

LOL!

I personally use 4 spaces (well my editors sets this when I 'tab' anyhow) - because I code in Perl most often, I think this is 'right' => http://www.perldoc.com/perl5.6/pod/perlstyle.html .

I think the style and clarity of your code is amazingly important - so is proper annotation and comments. I've been in a situation before where you take over from someone's else's code, and if it's messy code it makes your job a hundred times harder!

Cheers

- wil

openmind's picture

He has: 945 posts

Joined: Aug 2001

Gotta be one tab at a time 4 me. Only way I can keep track on what the hell I'm doing! Wink

Plus its doesn't half help when you're trying to track down those pesky closing tags!

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

Oh, BTW... PHP's PEAR Coding Standards states, "Use an indent of 4 spaces, with no tabs."

Mark Hensler's picture

He has: 4,048 posts

Joined: Aug 2000

This isn't fair!! :whine:

UNIX shell = 2 spaces
PHP, Perl = 4 spaces
VB = tabs

I also have my ASCII editor set to convert tabs to spaces. But I use M$ Visual Studio for VB, and I don't think they're advanced enough to include such a feature. Wink

I voted 4 spaces because I use PHP the most. Smiling

Mark Hensler
If there is no answer on Google, then there is no question.

mjames's picture

They have: 2,064 posts

Joined: Dec 1999

Tabs for me. I also love tidy code - that's why I use an ancient editor to format my code (AOLpress).

Suzanne's picture

She has: 5,507 posts

Joined: Feb 2000

I have my editor set to replace tabs with spaces, and the tab is set to 4. Can I answer both? Wink

I love tidy code. Not only easier to troubleshoot, but easier to simplify. I tend to write it all out in long code as I'm building something, then gradually boil it down like a good spaghetti sauce to the right bits, automating and building functions and such as I go.

Having tidy code and comments REALLY helps that process.

Peter J. Boettcher's picture

They have: 812 posts

Joined: Feb 2000

It is so much easier debugging clean code than messy, plus its a reflection on the type of person you are!

Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.