[OT] Auto code reformating / one coding style enforcment.

Chris Nicholson-Sauls ibisbasenji at gmail.com
Mon Aug 14 14:09:03 PDT 2006


Pragma wrote:
> Unknown W. Brackets wrote:
> 
>> In my code, I use hard tabs for everything and set my tab-width to 4 
>> spaces.
>>
>> I've never had trouble with printing code (something I do less often 
>> than have birthdays, mind you) nor any text editor displaying my code 
>> weirdly.
>>
>> Some people hate hard tabs, because they just have to line things up 
>> after a non-tab character with tabs.  I think this is a Bad Thing 
>> (TM), but if you have to do it, I understand using spaces.
>>
>> But I've never seen a case where a program would misbehave if the tab 
>> width was not set to 8.... I just can't wrap my head around the 
>> benefit of using both tabs *and* spaces.
>>
>> -[Unknown]
>>
>>
>>> Unknown W. Brackets wrote:
>>>
>>>> Uh-huh, sure.
>>>>
>>>> You're usually right, but I don't like having to hit backspace four 
>>>> times or 1 time alternatively based on my indentation level.  That's 
>>>> just bizarre.  I've never seen someone mix tabs like that before...
>>>>
>>>> Why do you prefer it, if I may ask?
>>>>
>>>> -[Unknown]
>>>>
>>>>
>>>>> It works just fine when you set tabs to be 8 characters, as god 
>>>>> intended them to be.
>>>
>>>
>>>
>>> Because it isn't screwed up when you type it to the screen or the 
>>> printer.
> 
> 
> For what it's worth, I think Sean is talking about code like this:
> 
> switch(x){
>     case 'foo':        break; // 2 tabs
>     case 'something':    break; // 1 tab
> }
> 
> On my display, with tab=8 spaces in Thunderbird, the 'break' statements 
> all line up perfectly. If your viewer has it set to something else (say 
> 4 spaces), it doesn't look right.  So its the /internal/ indentation 
> that fails here, as the left column will always look clean.
> 
> IMO, this is what code beautifiers are for.  I'm not going to worry 
> about inconsistent tabbing and spacing in any of my projects until 
> release time comes around anyway. ;)
> 

I'm strangely anal about my code being at least somewhat aesthetic to the eyes... a random 
habit I suppose I picked up from my original C++ teacher a decade ago.  It does help me 
when reading code, though, so I stick to using spaces whenever possible.  (Thank goodness 
for EditPlus's "insert tabs as spaces" setting, and for the Ctl+Arrow behavior of Windows 
cursors.)

-- Chris Nicholson-Sauls



More information about the Digitalmars-d mailing list