Difference between revisions of "Fully automatic indentation"

From Free Pascal wiki
Jump to navigationJump to search
(New page: =Overview= The source editor should auto indent on pressing return/enter, on paste and when inserting auto generated code. This depends on language and user preferences. Most other editor...)
 
Line 4: Line 4:
  
 
Fully automatic indentation tries to guess the rules from the surrounding code.
 
Fully automatic indentation tries to guess the rules from the surrounding code.
 +
 +
=Examples=
 +
 +
<Delphi>
 +
procedure Do;
 +
begin
 +
 
 +
end;
 +
</Delphi>
 +
 +
<Delphi>
 +
procedure Do;
 +
begin
 +
  if expr then
 +
  begin
 +
    Code;
 +
  end;
 +
end;
 +
</Delphi>
 +
 +
<Delphi>
 +
procedure Do;
 +
begin
 +
  if expr then begin
 +
    Code;
 +
  end;
 +
end;
 +
</Delphi>
 +
 +
<Delphi>
 +
procedure Do;
 +
begin
 +
  if expr then
 +
    begin
 +
    Code;
 +
    end;
 +
end;
 +
</Delphi>
 +
 +
<Delphi>
 +
procedure Do;
 +
begin
 +
  if expr then
 +
    begin
 +
      Code;
 +
    end;
 +
end;
 +
</Delphi>

Revision as of 13:17, 22 May 2009

Overview

The source editor should auto indent on pressing return/enter, on paste and when inserting auto generated code. This depends on language and user preferences. Most other editors use either a fixed set of rules or a set of options to configure the rules. This is semi automatic indentation. These options are either too simple or too complex. And they only allow one set of rules, so editing sources with different policies is difficult.

Fully automatic indentation tries to guess the rules from the surrounding code.

Examples

<Delphi> procedure Do; begin

end; </Delphi>

<Delphi> procedure Do; begin

 if expr then
 begin
   Code;
 end;

end; </Delphi>

<Delphi> procedure Do; begin

 if expr then begin
   Code;
 end;

end; </Delphi>

<Delphi> procedure Do; begin

 if expr then
   begin
   Code;
   end;

end; </Delphi>

<Delphi> procedure Do; begin

 if expr then
   begin
     Code;
   end;

end; </Delphi>