Ways to format your code in Keil using Astyle 2 articles

Source: Internet
Author: User

About Astyle

Astyle's full name is artistic style abbreviation, is an open source source code formatting tool, can be c,c++,c# and Java and other programming language source code indentation, formatting, landscaping.
Home page:http://astyle.sourceforge.net/
Project page:http://sourceforge.net/projects/astyle/

Integration of Astyle in Keilμvision (take Keilμvison4 as an example)

① Download Astyle, extract to any location (Astyle green software) (Win2.02.1 version, you can see the latest version of the official website)

Thousand Easy download: Http://1000eb.com/aguv
Blog Download: http://files.cnblogs.com/totop/AStyle_2.02.1_windows.zip

②ΜVISION4 Click the Tools menu---Customize tools menus

③ add Astyle all Files and Astyle current File menu (custom menu name, can be used in Chinese)

Two menus are added here, each of which formats the current file and formats all the files in project.

④ Add Command command: Click ... button, select Astyle.exe in the Astyle installation directory.

⑤arguments:
Astyle Current File menu fill in! E
Current file
Astyle All Files menu fill in "$E *.c" "$E *.h"
All. C and. h files in the same folder as the current file

⑥ actual use effect is as follows:

Transferred from: http://www.cnblogs.com/totop/archive/2012/07/04/keil-astyle.html

http://bbs.mydigit.cn/read.php?tid=410700

A good program, not only to have a good algorithm, but also need to have a good writing style. It's not easy to write a good algorithm, but a good code style is not difficult. Referring to the format code, Astyle is not a missed tool, it can easily format the program code into its own style without the need to manually modify, and it is green, free, open source. For Astyle help and download, please refer to its official website: http://astyle.sourceforge.net/.



The following describes the method of adding Astyle in Keil uVision4, the morning reference Keil Help manual, the implementation of Keil in a very convenient way to use Astyle, and we share, if you have better format code method, please do not begrudge your jade, I'm going to throw the bricks here.

Ways to add Astyle menus:
1:UVISION4 Click the Tools menu---Customize tools menus


2: Add Astyle all Files and Astyle current File menu (custom menu name, can be used in Chinese)
I've added two menus here, which are formatting the current file and formatting all the files in project.
3: Add command command: Click ... button, select Astyle.exe.
4:arguments:
Astyle Current File menu fill in! E
Astyle All Files menu fill in "$E *.c" "$E *.h"


Note:! E represents the file that is currently in focus and being edited.
$E *.c and $e*.h represent all. C and. h files that are currently in focus and are being edited in the directory where the files are located (refer to the Help document for Keil uvision)
Use the Astyle default format to format the file, or you can customize the format to refer to the Astyle Help document in the custom format. After the default format, the original file is backed up as the source file name. orig. If you do not want Astyle to back up your files, you can use the-n parameter. such as:-N! E (indicates the format of the current file, not backup)

Use effect in Keil: The resulting menu appears in the Tools drop-down menu, and Astyle's run structure appears in the Keil build Output window.

Format the results of the current file:Formatting results for all files:Backup files are generated by defaultReference Help is available: Astyle Help and Keil uVision4 help.  

//----------------------------------------------

-style=ansi:ansi style formatting and indentation

namespace foospace
{
int Foo ()   
{
if (Isbar)
{
Bar ();
return 1;
}
Else
return 0;
}   
}

--style=kr:kernighan&ritchie style formatting and indentation

namespace Foospace {
int Foo () {
if (isbar) {
Bar ();
return 1;
} else
return 0;
}
}

--style=linux:linux style formatting and indentation

namespace foospace
{
int Foo ()
{
if (isbar) {
Bar ();
return 1;
} else 
return 0;
}
}

--style=gnu:gnu style formatting and indentation

namespace foospace
{
int Foo ()
{
if (Isbar)
{
Ba R ();
return 1;
}
Else
return 0;
}   
}

--style=java:java style formatting and indentation

class Foospace {
int Foo () {
if (isbar) {
Bar ();
return 1;
} else
return 0;
}
}

Ways to format your code in Keil using Astyle 2 articles

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.