But it appears that the auto-completion code works seperately from the code formatting tool.

Thu Feb 07, 2008 3:42 pm

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6776

That's right. Code snippets have nothing to do with auto-completion. To get a better idea of code snippets are, type cfetch and then press Ctrl+Enter, pick some table. To use your own INSERT snippet, type ins and then Ctrl+Enter

Thu Feb 07, 2008 3:58 pm

KUGS4C

Joined: 07 Feb 2008Posts: 3Country: Kazakhstan

Thank you for your reply.

I would really have preferred if code completion were customized according to code formatting.

Perhaps this is something you consider interesting?

Fri Feb 08, 2008 1:09 pm

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6776

I can offer a solution for that.

1. Disable code completion feature for DDL statements (uncheck Auto Expand SQL Code option)
2. Create a snippet with the name INSERT and set the activation key to be a space character. Set the snippet case-sensitive option to False.
3. In the snippet, code what you want it to do. You may use to use macro-variables like $COLUMNS$ or $OBJECT$. There are plenty of examples available in the existing pre-configured snippets.

Hope this helps.

Fri Feb 08, 2008 1:24 pm

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6776

An alternative method is to use the reformat Ctrl+F11 function to convert the generated SQL as required, for example, to put commas in front.

Fri Feb 08, 2008 1:30 pm

KUGS4C

Joined: 07 Feb 2008Posts: 3Country: Kazakhstan

SysOp wrote:

Hope this helps.

Thanks, but it seems the macro-variable $COLUMNS$ is expands to a comma-and-space separated list.

As in this example:

Code:

CREATE TABLE foo (id int, bar int)

INSERT INTO foo
(
id, bar
, id, bar
)
SELECT

, where I defined the snippet to be:

Code:

INSERT INTO $OBJECT$
(
$COLUMNS$
, $COLUMNS$
)
SELECT |

CTRL+F11 works, of course, but it is a tad tiring to have to press this key-combination after every statement.

Possibly the application could automatically run a reformat of the newly-generated code after it is inserted in the editor.

Sat Feb 09, 2008 8:14 am

SysOpSite Admin

Joined: 26 Nov 2006Posts: 6776

At the time of the previous post I was thinking about

Code:

INSERT INTO $OBJECT$
(
,$COLUMNS$
)
SELECT |

Yet, it appears that symbols adjacent to macro variables have special treatment. Basically they are treated as user-defined prefixes and/or suffixes for auto-generated object and column names. I am going to submit an enhancement request for snippets to support vertical column format and positional control for commas.