CnPack Forum » CnWizards IDE Wizards » Can I automatically add "end" for "begin"?

2009-5-17 02:59 elricbk
Can I automatically add "end" for "begin"?


First of all — thanks for great Delphi instrument!

My question is — can I emulate in some way with CnPack the Delphi 2009 behaviour with "begin .. end"? I want to input "begin", press "enter" and after that "end" should be automatically entered with proper indentation and my cursor should be placed with proper indentation too. I now that I can use the "be" shortcut for this, but could it be done automatically without delay for choosing "be" shortcut?

Thanks in advance for your answer.

2009-5-18 07:50 Passion
Thanks for your suggestion. We'll consider it.

2009-5-18 20:11 Passion
Please try our latest nightly build version?


We add this funtion in

2009-5-19 00:58 elricbk
Thanks for fast realization of this feature. Tried last unstable build: "end" was automatically added, but my settings for tab indent was not used, so after adding "end", cursor was indented for two spaces instead of four. Found no way to change this behavior. Did I miss something?

[[i] Last edited by  elricbk at 2009-5-19 01:18 [/i]]

2009-5-19 07:09 Passion
I'll check this problem.

2009-5-29 14:45 elricbk
Tested latest nightly build ( from GoogleCode). All works flawlessly. Thanks a lot!

2009-6-4 01:25 elricbk
Found some unexpected behavior. If I press 'enter' while standing at any line with 'begin', CnPack would automatically add 'end' for it. Suppose the situation:

[code]for i := 0 to 10 do




Now, I want to add some lines to beginning of the loop (before the 'writeln'), I put cursor on the line with 'begin' and hit 'enter':

[code]for i := 0 to 10 do






This is what I get ('|' stands for cursor position). Is it possible to fix it some way? For example, add 'end' only if 'n' + 'enter' was typed? Or something like this. Thanks in advance.

UPD: [code][/code] tag just wants to double all the newlines, so code looks sparsed. Don't know how to change it.

[[i] Last edited by  elricbk at 2009-6-4 01:27 [/i]]

2009-6-4 07:27 Passion
Thanks for your report. Some friends also report the same problem.

Please try our latest nightly build

2009-6-6 02:38 elricbk
Tried the version. So after some quick tests, I believe, now it works as intended... but only for those, who follows the indentation rules :) And it wroks really strange for those, who don't.

For example, suppose empty unit, where you start writing you first procedure:
[code]unit Unit1;



procedure Test;



So, now I hit 'enter' and wait for 'end' to appear. But whops! nothing happens.

Ok, let's move to next example:
[code]procedure Test;


   i: Integer;


for i := 0 to 10 do



Again, after 'enter' nothing happens. And even if I put one space before 'for', it would still behave the same.

I'll stick with this version for a moment, because it seems to work right in my day-to-day use, but for someone else its behaviour may seem strange.

Also, have another one suggestion, now for 'end' :) Could 'end' input be possibly done as '}' input in many C editors. I.e.,

[code]for (i = 0; i < 10; i++)


    print "Hi, world!\n";

Now, if I input closing bracket, it would jump to the beginning of line, like this:
[code]for (i = 0; i < 10; i++)


    print "Hi, world!\n";


In Delphi rule should work like this: if 'end;' was inputted, and there is only 'end;' in this line, then indendation should be decreased by one full indent. Or something like this. THanks in advance!

UPD: Shouldn't the [code] output be in monospaced font?

[[i] Last edited by  elricbk at 2009-6-6 02:41 [/i]]

2009-6-6 02:48 elricbk
Also, did you try to fix [code] newline problem? Because it seemed to work correctly when I used Reply buuton, but after I used [Edit] problem with newlines arose again.

2009-6-6 22:09 Passion
Thanks for your detailed report. We do some fix in against the 2 problems in you report. But in fact, "unmatched" begin end is relatively not easy to distinguished precisely. We use the indent tab and some other nested level to do the judgement. Maybe cause some uncorrect "auto end".:L

2011-11-3 06:51 corrie
Is it possible to add a newline as well as an end?

I often encounter this:

procedure TForm1.NewMethod;
end;//<<-- Automatically inserted END;, but now I have to manually correct put a new line after it
procedure TForm1.ExistingMethod;

页: [1]

Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.