Subject: Can I automatically add "end" for "begin"? [Print This Page]
Author:
elricbk Time: 2009-5-17 02:59 Subject: Can I automatically add "end" for "begin"?
Hi!
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.
Author:
Passion Time: 2009-5-18 07:50
Thanks for your suggestion. We'll consider it.
Author:
Passion Time: 2009-5-18 20:11
Please try our latest nightly build version?
http://www.cnpack.org/downbuilds.php
We add this funtion in 0.9.1.509.
Author:
elricbk Time: 2009-5-19 00:58
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?
[ Last edited by elricbk at 2009-5-19 01:18 ]
Author:
Passion Time: 2009-5-19 07:09
I'll check this problem.
Author:
elricbk Time: 2009-5-29 14:45
Tested latest nightly build (0.9.1.512 from GoogleCode). All works flawlessly. Thanks a lot!
Author:
elricbk Time: 2009-6-4 01:25
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:
for i := 0 to 10 do
begin
Writeln('Test');
end;
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':
for i := 0 to 10 do
begin
|
end;
Writeln('Test');
end;
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.
[ Last edited by elricbk at 2009-6-4 01:27 ]
Author:
Passion Time: 2009-6-4 07:27
Thanks for your report. Some friends also report the same problem.
Please try our latest nightly build 0.9.2.516?
Author:
elricbk Time: 2009-6-6 02:38
Tried the 0.9.2.516 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:
unit Unit1;
interface
implementation
procedure Test;
begin|
end.
So, now I hit 'enter' and wait for 'end' to appear. But whops! nothing happens.
Ok, let's move to next example:
procedure Test;
var
i: Integer;
begin
for i := 0 to 10 do
begin|
end;
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.,
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:
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?
[ Last edited by elricbk at 2009-6-6 02:41 ]
Author:
elricbk Time: 2009-6-6 02:48
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.
Author:
Passion Time: 2009-6-6 22:09
Thanks for your detailed report. We do some fix in 0.9.2.518 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".
Author:
corrie Time: 2011-11-3 06:51
Is it possible to add a newline as well as an end?
I often encounter this:
procedure TForm1.NewMethod;
begin
|
end;//<<-- Automatically inserted END;, but now I have to manually correct put a new line after it
procedure TForm1.ExistingMethod;
begin
...
...
...
end;
Welcome to CnPack Forum (http://bbs.cnpack.org/) |
Powered by Discuz! 5.0.0 |