andreasklockner

LPCXpresso - templates - code formatter

Discussion created by andreasklockner on Aug 18, 2016
Latest reply on Aug 18, 2016 by LPCX presso support

At the moment I have problems with code templates in conjunction with the formatter.

 

- I have edited an own profile for the formatter (Preferences->C/C++->Code Style->Formatter)

- I have configured the code templates (Preferences->C/C++->Editor->Templates) to "use code formatter"

     ("use code formatter" check box is active.  Thus I expect LPCXpresso to 'ignore' the format of the

     existing templates and use the Code Style, which I have edited in the formatter. )

 

So I think, LPCXpresso will format my code in the same way,

if I use "auto-complete" (CTRL+Space) or if I use the formatter

for existing code.

 

But these two methods lead to different code formatting:

 

Exampe for "switch" statement:

 

Using auto-complete (typing "sw" and pressing CTRL+Space) results in:

(this is NOT the result I want to have)

 

switch (key)

{

    case value:

   

    break;

    default:

    break;

}

 

Using the formatter afterwards (mark the code + SHIFT+CTRL+F) results in:

(this is the result I want to have)

 

switch (key)

{

case value:

   

    break;

default:

    break;

}

 

It seems, that the auto-complete function catches some rules, but

not ALL rules from the formatter...?

 

Or am I missing something?

 

------------------------------------------------------------

PS:

I'm using:

- Win7

- LPCxpresso v7.9.2

 

The template for "switch" is defined like this (Preferences->C/C++->Editor->Templates):

 

switch (${key}) {

    case ${value}:

        ${cursor}

        break;

    default:

        break;

}

Outcomes