Indenting: spaces or tabs?
-
I'm using VS.NET for heavy editing and notepad... for everything else :) Actually it's not when using a single program that I notice the difference, but when I have to use different editors. If only notepad had the Tab Size option... BTW, which programming tools are you using? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
I mainly use VS.NET and UltraEdit. UltraEdit is the one of the best text editors I've seen to date. Highly configurable, but the default configuration rocks! The other editor which brings me good memories is Boxer (for DOS, unfortunately - the Windows version sucks). Concussus surgo. When struck I rise.
-
Ditto... in vi, notepad, vc++, etc. - Jason (SonorkID 100.611) The Code Project - Orange makes the art grow fonder
Ahhh, vi. Man's favourite editor. Or: how to make something incredibly difficult, which could be made very easy so that only true geeks can use it... New and improved: kwakkelflap.com "When I hear of Schrödinger's cat, I reach for my gun." - Stephen Hawking
-
Use the DOS editor...;P The following statement about your geekness is true. The previous statement about your geekness is not true. GCS/IT/P d- s: a- C++++$ UL+>++++ P+ L++$ E- W+++$ N !o K+ w++$ O---- M-- PS- PE Y+ PGP--- t !5 X- tv b+++ DI++ D+ G++ e++ h--- r+++
Real programmers use EDLIN. (although the best programmer's editor was TECO on the DEC PDP-11 under RT-11)
"Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle
-
A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
2 spaces !!
-
Tabs, without a doubt. I can't understand why you would use spaces when you can set the editor to indent tabs by x for you.
8
SIMON WALTON
SONORK ID 100.10024Depends on your alignment preferences, and the TAB's other people use: if you always only care about left indentation, it's almost no problem. however, for thing like
case eOphelia: // is it her?
if (act.inRiver) // yes ==> dead already?
act.dead = true; // yes ==> force dead
// (simon always forgets to update flags)now look at it on a system with a different TAB width...
Auch den Schatten will ich lieben weil ich manchmal lieber frier' Rosenstolz [sighist]
-
Tabs set to 4 spaces. And I usually ident code with open and close braces on a separate row: ex: if () { } else { } Here you'll find some code idented in a funny way :) P.S. In some languages (python, for example) identing is mandatory. -- Looking for a new screen-saver? Try FOYD: http://digilander.iol.it/FOYD
Welcome to your new job, Mr Walton. There's a serious stack overflow bug in this code, we'll need you to solve it by, oh, noon. Or you're fired.
8
SIMON WALTON
SONORK ID 100.10024 -
Real programmers use EDLIN. (although the best programmer's editor was TECO on the DEC PDP-11 under RT-11)
"Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle
I quite liked "vi". I know I tend towards the "why do things the hard way when there's lovely tool to do it for you?" school of thought but vi was incredibly easy once you'd been using it for a while. Most of the commands were instinctive (but it was always helpful to have a quick reference guide around, just in case) just like anything else after using it constantly for a few weeks. Paul
-
A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
Luca Leonardo Scorcia wrote: And yours? Tabs set to 1 (in HTML you can get very deeply nested, having Tab set to 4 or 8 means the first letter of a line can start off the page, so 1 is the only option.) No idea why people use spaces. Someone once mentioned it is better for printing, but I never saw any proof.
Paul Watson
Bluegrass
Cape Town, South Africa -
If you are worried about tabs and spaces you're using the wrong set of programming tools... :zzz: :zzz: :zzz: Concussus surgo. When struck I rise.
Daniel Turini wrote: you're using the wrong set of programming tools... So what tools should we be using? Just curious :)
Paul Watson
Bluegrass
Cape Town, South Africa -
Real programmers use EDLIN. (although the best programmer's editor was TECO on the DEC PDP-11 under RT-11)
"Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle
Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}
-
Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}
Been there, done that. When I took Data Structures in college, programming was on the IBM 370 mainframe, using punch cards. We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. I helped him do a 'floor sort' one time; it was a good thing he liked sequence numbers in columns 73-80.
"Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle
-
A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
I use tabs. :)
43 68 65 65 72 73 2c 4d 69 63 68 61 65 6c
-
Been there, done that. When I took Data Structures in college, programming was on the IBM 370 mainframe, using punch cards. We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. I helped him do a 'floor sort' one time; it was a good thing he liked sequence numbers in columns 73-80.
"Think of it as evolution in action." - 'Oath of Fealty' by Larry Niven and Jerry Pournelle
Gary Wheeler wrote: We had a guy in our class who was blind. This guy read the holes in the cards with his fingers. :cool: Very impressive! I guess having used cards helps to appreciate the speed and convenience we have today. And to think I used to gripe about waiting for the cassette drive to finish loading. BW {insert witty/thought-provoking saying here}
-
A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
Tabs set to 4 spaces. Jason Gerard
-
I want to use tabs but have to use spaces, and it sucks.. X| With tabs everybody can have the tabwidth they want. If you want to delete the tab you just type you only have to press backspace once. Easier to reformat the code. I cant see a single advantage with using spaces. /Magnus
- I don't necessarily agree with everything I say
I cant see a single advantage with using spaces. Because if you have your tabs set differently from me, any indentation other than the beginning-of-line, one-tab indentation gets screwed up. It's mostly a problem when you use end-of-line comments, aligned variable initializations, or indentation for the definition of long functions, all shown below:
sometype_t CSomeClass::SomeRandomFunction(footype_t arg1,
footype_t arg2)
{
somestruct_t thing;
thing.a = -1;
thing.longerName = 10;
thing.evenLongerName = 5;doSomething(); // And explain why doSomethingElse(); // And explain that, too doSomethingWithALongName(); // And this one, too
}
The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! ;-) Tim Lesher http://www.lesher.ws
-
Gary Wheeler wrote: Real programmers use EDLIN. no,nononono. REAL coders use punch cards. :rolleyes: BW {insert witty/thought-provoking saying here}
REAL coders use punch cards. And REAL coders who won't/can't adapt are on the dole. ;-) Tim Lesher http://www.lesher.ws
-
I cant see a single advantage with using spaces. Because if you have your tabs set differently from me, any indentation other than the beginning-of-line, one-tab indentation gets screwed up. It's mostly a problem when you use end-of-line comments, aligned variable initializations, or indentation for the definition of long functions, all shown below:
sometype_t CSomeClass::SomeRandomFunction(footype_t arg1,
footype_t arg2)
{
somestruct_t thing;
thing.a = -1;
thing.longerName = 10;
thing.evenLongerName = 5;doSomething(); // And explain why doSomethingElse(); // And explain that, too doSomethingWithALongName(); // And this one, too
}
The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! ;-) Tim Lesher http://www.lesher.ws
Tim Lesher wrote: The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. :) So this arugment does not hold. Tim Lesher wrote: And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! Where did you get that from? I never said that, and i never would say so..... /Magnus
- I don't necessarily agree with everything I say
-
Spaces at four; whitesmith (Microsoft)-style indenting
int func()
{
for (int i=0; i< 4; ++i)
{
// Like This
;
}
return 0; // With no parens around the zero, dammit!
}Tim Lesher http://www.lesher.ws
Bah... article thread view appears to get rid of initial spacing. Tim Lesher http://www.lesher.ws
-
A little survey about your code-indent style... what do you use? Spaces or tabs? I used to do a mix of tabs and spaces, but the code looked awful when edited with VS and then opened with notepad for a quick look. So I started using only spaces, but I noticed that for some files indentation made the file size grow a lot... now I'm using only tabs. I think that's the best way: any serious code editor can set the tab size to any number of space you want, code in notepad looks fine, and it's faster to type and files don't get too large. These are my 2 cents. And yours? Luca Leonardo Scorcia http://zip.to/kojak (only in Italian)
Spaces at four; whitesmith (Microsoft)-style indenting
int func()
{
for (int i=0; i< 4; ++i)
{
// Like This
;
}
return 0; // With no parens around the zero, dammit!
}Tim Lesher http://www.lesher.ws
-
Tim Lesher wrote: The arguments won't line up if you use tabs at a different width than me, but they will line up if you use spaces But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. :) So this arugment does not hold. Tim Lesher wrote: And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! With 80GB hard drives costing less than US$79, what's the point? Do you also use i, j, k, and l for variable names to save space?! Where did you get that from? I never said that, and i never would say so..... /Magnus
- I don't necessarily agree with everything I say
But there is no problem pressing the space key even if the tabkey produces *drumroll* tabs. Correct, but Dev Studio auto-indents the arguments for you, and if you have tabs as your default, it uses a mixture of spaces and tabs. Of course, the error may be relying on Dev Studio's auto indent. It also butchers long for statements if you break after each semicolon. And the argument that spaces take up more disk space than tabs? Geez, what a non-starter! Where did you get that from? I never said that, and i never would say so..... You didn't, but it was mentioned in the thread, and I couldn't be bothered to go back and put it after the right response... :-) Tim Lesher http://www.lesher.ws