Auto Completion in Lazarus

I have found these days a new auto-completion feature that already exist in Lazarus, it is variables auto-completion. Previously I was only using procedure header / method auto-completion, by typing method header inside class definition part then clicking Ctrl-Shift-C to get implementation part of the procedure/method.

Now someone in Lazarus forum told us that auto completion is available for variables, for example, you can write for loop without defining loop variable first:

 


begin
  for i:= 1 to 10 do
    Writeln(i);
end.

Then stop in i variable and click Ctrl-Shift-C and you will get an automatic definition with a proper type:

 


var
  i: Integer;
begin
  for i:= 1 to 10 do
    Writeln(i);
end.

 

Also you can use it with parameter values:


procedure getRandomNumber(var x: string);
begin
  x:= Random(100);
end;

begin
  GetRandomNumber(MyNumber);
  Writeln(MyNumber);
end.

 

Then stop at MyNumber and click Ctrl-Shift-C to get:


procedure getRandomNumber(var x: Integer);
begin
  x:= Random(100);
end;

var
  MyNumber: Integer;
begin

  GetRandomNumber(MyNumber);
  Writeln(MyNumber);

end.

I found it very useful, so that I liked to share.

Now you can stop defining variables before using it, just use the variable and auto-define it later.

One thought on “Auto Completion in Lazarus

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s