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

Walter Bright newshound at digitalmars.com
Mon Aug 14 17:41:53 PDT 2006


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