Topic: Request for Smart Indenting (1 of 9), Read 65 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Thursday, February 10, 2000 10:25 PM

As you may know, VEDIT has "template editing" for C. If you type "if ", it expands to

if (...) {
...
}

I am hoping that someone might have the time to enhance this to also perform simple "smart indenting". E.g. if you type "{" at the end of a line, it starts the next line indented by an additional 4 spaces. Similarly, when you type "}" on a new line, it immediately undents the line.

Thank you.

Ted Green.

 


Topic: Request for Smart Indenting (2 of 9), Read 63 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Friday, February 11, 2000 09:10 AM

Maybe I just misunderstood it, but at least for my style of editing programs I can't imagine that helpful. (Sorry ;-)) )

I'm using the Auto-Indent mode in combination with two key assignments:

Smart-TAB and Smart-Backspace:

ftp://ftp.vedit.com/share/smart-t&b.vdm

(The macros are not yet documented at the moment because of lack of time. But you are __THE__ expert for VEDIT macros.)

Especially my Smart-Backspace seems to be nearly that what you want, I think.

Maybe it helps.
(If necessary I can post more infos.)


Christian

 


Topic: Re: Request for Smart Indenting (3 of 9), Read 65 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Friday, February 11, 2000 09:34 AM

Take the C program:

main()
{
int i;
for (i=1; i<10; i++) {
doit(i);
}
}

void doit( int i )
{
printf("The number is %d",i);
}

With the smart-indent I have in mind, the entire program could be
entered without having to manually indent the code or press any
function keys.

Ted.

 


Topic: Re: Request for Smart Indenting (4 of 9), Read 64 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Friday, February 11, 2000 12:03 PM

>With the smart-indent I have in mind, the entire program could be
>entered without having to manually indent the code or press any
>function keys.

Now it's clear.
O.k. I'll think about it (dependent on the weather at the weekend and
.... and ...).

There are some ideas in my mind.
One problem I see is: The first Char(-1) in C.VTM would navigate just
into the CR/LF after the brace. Interesting task...

But hey, there are +133 registered users here in the WebBoard.
What about them? ;-)


Christian

 


Topic: Re: Request for Smart Indenting (5 of 9), Read 63 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Monday, February 14, 2000 06:22 AM

Here is my solution:

ftp://ftp.vedit.com/share/c-z1.vtm

Is that the function you have in mind?

If yes, I will work on it a little bit more to make a version 1.0 ... :-)


Christian

 


Topic: Re: Request for Smart Indenting (6 of 9), Read 68 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Monday, February 14, 2000 02:17 PM

Christian:

Thank you very much for your work on c-z.vtm; I see that it is more
complicated than I anticipated. I have slightly improved your file
and uploaded it as:

ftp://ftp.vedit.com/share/c.vtm

It appears that I must make some modifications to VEDIT in order to
really make it work as desired. Consider:

main() { //A comment
return;
}

What I really want is that after "{" is typed that the indent for the
next line is increased. To make this work, the key must
call the event macro after inserting the CR+LF, but before adding the
indent.

I would suggest not making any further changes to c.vtm until I make
some enhancements to VEDIT itself.

Ted.

 


Topic: Re: Request for Smart Indenting (7 of 9), Read 69 times
Conf: VEDIT Macro Library
From: Christian Ziemski
Date: Monday, February 14, 2000 04:40 PM

Ted:

>I have slightly improved your file and uploaded it as..

I'll have a look at it tomorrow. Now it's sleeping time.


>Consider:
>
>main() {    //A comment
>    return;
>}
>
>What I really want is that after "{" is typed that the indent for the
>next line is increased. To make this work, the key must
>call the event macro after inserting the CR+LF, but before adding the
>indent.

If there would be no comment in your example I think my macro does the
indention as you want (Maybe you used the "old" version 0.9?).
After pressing "{" the cursor jumps into the second line, 4 characters
indented after the beginning of "main". Here you can type "return".

Or do you mean the key _after_ the comment should be so
intelligent to find the "{" and to indent the 2nd line then?
THAT would be tricky indeed...

>I would suggest not making any further changes to c.vtm until I make
>some enhancements to VEDIT itself.

We'll see...
What enhancements do you mean?


Christian


PS:
If you (or someone other) are posting some formatted text like the
indented code examples via _mailing_list_, the indention will be
destroyed by the HTML parser of WebBoard!
It is only visible if received via email, not via browser.
In this email-reply I'm using the HTML-Code "&nbsp;" ( ) for
spaces in the code.

 


Topic: Re: Request for Smart Indenting (8 of 9), Read 63 times
Conf: VEDIT Macro Library
From: Pauli Lindgren
Date: Wednesday, February 16, 2000 04:12 AM

On 2/11/00 9:34:19 AM, Ted Green wrote:

> With the smart-indent I have in mind,
> the entire program could be entered
> without having to manually indent the code
> or press any function keys.

I guess you mean a smart indent similar to that on Visual C++. I have never found any need for that. The template editing does it better.

The only additional thing needed is the keyboard macro I have defined for key Alt-{.
It inserts {} pair with an empty indented line in between, and moves cursor to that line. The auto indent mode handles rest.
Thus, your example program can be entered without having to manually indent the code or press any function keys.

On my keyboard, entering alt-{ is actually easier than entering a single '{' which requires pressing Alt-Gr key.

Of course, I am using my enhanced template macro that I made a couple of years ago.
I will upload it here as soon as I have written some documentation.

Meanwhile, here is the keyboard macro:

[RETURN]}[LINE BEGIN][CURSOR LEFT]{[RETURN][INDENT]

- Pauli

 


Topic: Re: Request for Smart Indenting (9 of 9), Read 67 times
Conf: VEDIT Macro Library
From: Ted Green
Date: Wednesday, February 16, 2000 11:31 AM

Thank you for your simple but clever macro.
Nonetheless, smart indenting will be added to
VEDIT very soon as part of the template editing.

Ted.