This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

HOW TO : auto formatting code in µvision version 4

Dear all,

I was a user if IAR, and in IAR there was a function which is called " auto indent". When you use it, it can auto formatting your code, make it more clear to read.

For example :

When you type below ( usually copied from another text file which was not tabified correctly):

void SetupData(uint16_t data)
         {
data=data<<8;
             GPIOB->ODR=(data);
}

Use the function Auto Indent with this block of code can auto formatting your code as below :

void SetupData(uint16_t data)
{
  data=data<<8;
  GPIOB->ODR=(data);
}

I want to know if Keil and µvision can do it, it saves a lot of time for me. Without this function, i won't buy µvision but will investe in IAR tools.
Thank all,

  • Are you aware that you can have that function whatever IDE you are using?

    There exists this excellent program named 'indent' (others exists too) that can indent a source file.

    So if you find the Keil IDE lacking, you can always create an indent profile and map a menu command to run an external program that performs the code reformatting.

    By the way: now we know you are the type of person who likes to include threats in your communication.

  • Hi Westermark, Thank for your quick answer. I don't really understand why you said " the type of person who likes to include threat". It was only my point of view and my choice after 3 days of using µVision, and i have used IAR for 3 years in my last company.

    I want just let you know that when i have used IAR for 3 years and i always want to compare between IAR and KEIL because i love all debug utilities in µvision, they are more friendly than IAR. And more, writting code is a habit, if you have to change the tool, you always wish to have some same little functions which you got used to.

    That's why my question is HOW TO ( i'm sure that IT CAN ) but HOW . Can we intergrate the function auto formatting code in µvision itself ? And then auto formatting code by a short cut for example.

    Thx

  • I don't run any recent uVision (yes, I have a valid license but all projects I work with are certified using older tool versions) so I haven't checked what may have changed in recent versions of the tools.

    But uVision have a Tools menu. And it contains a choice Customize Tools Menu...

    Select that command and then press the Help button - that should give you enough information to get uVision to run external programs to process the contents of files you have selected in the editor.

    And as I said, indent is a quite good program - and there are other tools with similar capabilities.

    So you just press a key or select a menu choice to run your source file through indent.

  • BY THE WAY : now we know you are the type of person who don't want to assume his negative point.
    A good engineer see every critic as a point to improve himself, I CAN'T AWARE THAT I CAN HAVE THIS FUNCTION whatever IDE i'm using, but I WANT IT in KEIL if i have to pay 5k€ to buy it !!!

  • Hi,

    JUST FORGET MY BY THE WAY, it was a joke, and thank for your advice about Indent anyway.

    I will try it and give some feedback to HOW TO.

    Thx

  • OK,

    The astyle is really interesting to format your code. But HOW TO intergrate it in KEIL to use it quickly, i don't know how to do it ( reseache for some hours but can't find anything)

    It's sad when KEIL don't have.. or i don't know

    KR,

  • It's sad when KEIL don't have.. or i don't know

    No. It's an opportunity for you to develop a deeper understanding.

  • The Artistic Style distribution includes an exe file that can process a source file when the file name is given on the command line.

    Did you look at the information I did post, about the Tool menu in uVision, and how to add own menu choices there?