[OT] Auto code reformating / one coding style enforcment.
Sean Kelly
sean at f4.ca
Tue Aug 15 08:51:08 PDT 2006
Regan Heath wrote:
> On Mon, 14 Aug 2006 18:23:27 -0700, Sean Kelly <sean at f4.ca> wrote:
>> Regan Heath wrote:
>>> 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).
>>
>> What about:
>>
>> int x,
>> y,
>> z;
>>
>> if( x == y ||
>> y == z )
>> {
>> func( x,
>> y,
>> z );
>> }
>
> No problem. The above is formatted like so:
>
> <t>int<s>x,<cr>
> <t><s><s><s><s>y,<cr>
> <t><s><s><s><s>z;<cr>
> <cr>
> <t>if(<s>x<s>==<s>y<s>||<cr>
> <t><s><s><s><s>y<s>==<s>z<s>)
> ..etc..
>
> you get the idea. where: <t> = tab, <s> = space
>
> The rule "hard tabs first, spaces following" implies you cannot mix tabs
> and spaces, meaning, your line starts with tabs (denoting the left hand
> margin) then has characters or spaces but never another tab, therefore
> <t><s><t> or <s><t><s> is illegal.
Oh I see, you place the restriction at the column level. That would
work, though it would mean holding down my spacebar a lot :-)
> I'll agree, trying to get a bunch of people to actually use the same
> formatting, or even to format their code consistently is nearly
> impossible.. in my ideal world I would have an editor which
> auto-formatted code that I was reading (regardless of the on-disk,
> in-file, actual format..) now that would be nice.
I bet emacs could be made to do this with some work, though it would
save files in the same formatting.
Sean
More information about the Digitalmars-d
mailing list