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

Unknown W. Brackets unknown at simplemachines.org
Mon Aug 14 21:28:47 PDT 2006


I'm assuming you have some interest in this conversation since you 
responded.  I mean not to encourage or start a flame war, but I fear I 
have (again; I think I've done this before!) asked a tricky question.... 
just wanted to know, mainly.

Anyway, it really is a shame that tab stops in <pre> are, according to 
the spec, 8 characters in width.  Of course, the spec also says not to 
use them:

http://www.w3.org/TR/html4/struct/text.html#h-9.3.4

Anyway, it's typically trivial to replace tabs with spaces in such code 
sections.  Since tabs should only be used in sequence from the left 
gutter (if you plan for them to line up), this is trivial.

When printing, I believe many text editors do send to the printer as 
spaces (not tabs.)  Perhaps I am mistaken.

I follow the rule described, and it never causes me problems.  I simply 
never line things up.  I use tabs only for indentation, and spaces for 
lining things up.  Anything else causes problems.

-[Unknown]


> Regan Heath wrote:
>> On Mon, 14 Aug 2006 10:27:11 -0700, Walter Bright 
>> <newshound at digitalmars.com> wrote:
>>> Frits van Bommel wrote:
>>>> Oh, and if you prefer 8-space indentation, I'd like to suggest you 
>>>> use hard tabs (consistently!) so others can easily view it at 4 
>>>> spaces (or whatever their personal preference may be).
>>>
>>> My screen ain't wide enough for that.
>>
>> Sure it is. Your preference is for 4 space wide indentation, all you 
>> have to do is tell your editor to display a hard tab as 4 spaces (as 
>> any editor worth it's salt can do) and use hard tabs everywhere.
>>
>> Problem #1 solved.
>>
>> In fact, if you do this and discover some code is too wide for 4 space 
>> indentation, simply set tabs to 2 spaces (temporaily) to read that 
>> code, then set it back. Isn't that nice? and flexible?
>>
>> I suspect if you print this code, and the editor sends actual hard 
>> tabs to the printer they'll probably be 8 spaces wide.. but:
>> 1. who prints code?!?
> 
> I do. I also put code in html <pre>...</pre>, where tabs are 8. I put 
> code in emails, where tabs are 8. I print code on the console, where 
> tabs are 8. I send code to other operating systems, where tabs are 8.
> 
>> 2. the editor _should_ instead send your specified # of spaces instead 
>> of hard tabs.
>>
>> Problem #2 solved.
> 
> Send it to where? The disk file? Then there aren't tabs in it anymore.
> 
>> Oh, and for those who want to align text on seperate lines remember 
>> the golden rule; "hard tabs first, spaces following" and you'll have 
>> no problems. Regardless of the viewers tab width the lines will align. 
>> (ignoring non fixed-width fonts, for which no solution involving 
>> spaces/tabs will work).
>>
>> Problem #3 solved.
> 
> Not really, because I follow that rule, and if tabs are set to 3 it gets 
> all screwed up.



More information about the Digitalmars-d mailing list