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

Regan Heath regan at netwin.co.nz
Mon Aug 14 16:49:06 PDT 2006


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?!?
2. the editor _should_ instead send your specified # of spaces instead of  
hard tabs.

Problem #2 solved.

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.

Regan



More information about the Digitalmars-d mailing list