Skip to content

Instantly share code, notes, and snippets.

@derofim
Created August 27, 2016 13:11
Show Gist options
  • Save derofim/49a1d0eea566230567ac36f0f386f27b to your computer and use it in GitHub Desktop.
Save derofim/49a1d0eea566230567ac36f0f386f27b to your computer and use it in GitHub Desktop.
Astyle code automatic formatting settings
# @file Astyle code automatic formatting settings
# @see http://astyle.sourceforge.net/astyle.html#_General_Information
#
# "One True Brace Style" uses linux brackets and adds brackets to unbracketed one line conditional statements.
# Opening brackets are broken from namespaces, classes, and function definitions.
# Brackets are attached to everything else including statements within a function, arrays, structs, and enums.
# In the following example brackets have been added to the "return 0;" statement. The option ??add?one?line?brackets can also be used with this style.
#
# int Foo(bool isBar)
# {
# if (isFoo) {
# bar();
# return 1;
# } else {
# return 0;
# }
# }
#
--style=otbs
#
# Indent using # spaces per indent (e.g. -s3 --indent=spaces=3 ). # must be between 2 and 20. Not specifying # will result in a default of 4 spaces per indent.
#
--indent=spaces=4
#
# Attach brackets to a namespace statement. This is done regardless of the bracket style being used.
#
--attach-namespaces
#
# Attach brackets to a class statement. This is done regardless of the bracket style being used.
#
--attach-classes
#
# Attach brackets to class and struct inline function definitions. This is not done for run-in type brackets (Horstmann and Pico styles). This option is effective for C++ files only.
#
--attach-inlines
#
# Attach brackets to a bracketed extern "C" statement. This is done regardless of the bracket style being used. This option is effective for C++ files only.
#
--attach-extern-c
#
# Indent 'class' and 'struct' blocks so that the entire block is indented.
# The struct blocks are indented only if an access modifier, 'public:', 'protected:' or 'private:', is declared somewhere in the struct. This option is effective for C++ files only.
#
# --indent-classes
#
# Indent 'class' and 'struct' access modifiers, 'public:', 'protected:' and 'private:', one half indent.
#
--indent-modifiers
#
# Indent 'switch' blocks so that the 'case X:' statements are indented in the switch block. The entire case block is indented.
#
--indent-switches
#
# Indent 'case X:' blocks from the 'case X:' headers. Case statements not enclosed in blocks are NOT indented.
#
# --indent-cases
#
# Add extra indentation to namespace blocks. This option has no effect on Java files.
#
# --indent-namespaces
#
# Add extra indentation to labels so they appear 1 indent less than the current indentation, rather than being flushed to the left (the default).
#
# --indent-labels
#
# Indent preprocessor blocks at bracket level zero, and immediately within a namespace.
# There are restrictions on what will be indented. Blocks within methods, classes, arrays, etc, will not be indented.
# Blocks containing brackets or multi-line define statements will not be indented. Without this option the preprocessor block is not indented.
#
--indent-preproc-block
#
# Indent multi-line preprocessor definitions ending with a backslash. Should be used with --convert-tabs for proper results.
# Does a pretty good job, but cannot perform miracles in obfuscated preprocessor definitions.
# Without this option the preprocessor statements remain unchanged.
#
--indent-preproc-define
#
# Indent preprocessor conditional statements to the same level as the source code.
#
# --indent-preproc-cond
#
# Indent C++ comments beginning in column one. By default C++ comments beginning in column one are assumed to be commented?out code and not indented.
# This option will allow the comments to be indented with the code.
#
--indent-col1-comments
# Set the minimal indent that is added when a header is built of multiple lines. This indent helps to easily separate the header from the command statements that follow.
# The value for # indicates a number of indents and is a minimum value. The indent may be greater to align with the data on the previous line.
# The default value is 2, two additional indents.
# --min-conditional-indent
# Set the maximum of # spaces to indent a continuation line. The # indicates a number of columns and must not be greater than 120.
# If no # is set, the default value of 40 will be used.
--max-instatement-indent=100
#
# Pad empty lines around header blocks
#
--break-blocks
#
# Pad empty lines around header blocks (e.g. 'if', 'for', 'while'...). Treat closing header blocks (e.g. 'else', 'catch') as stand-alone blocks.
#
# --break-blocks=all
#
# Insert space padding around operators. Any end of line comments will remain in the original column, if possible. Note that there is no option to unpad. Once padded, they stay padded.
#
--pad-oper
#
# Insert space padding around parenthesis on both the outside and the inside. Any end of line comments will remain in the original column, if possible.
#
#--pad-paren
#
# Insert space padding around parenthesis on the outside only. Parentheses that are empty will not be padded.
#
# --pad-paren-out
#
# Insert space padding around the first parenthesis in a series on the outside only.
#
# --pad-first-paren-out
#
# Insert space padding around parenthesis on the inside only.
#
# --pad-paren-in
#
# Insert space padding between a header (e.g. 'if', 'for', 'while'...) and the following paren.
# Any end of line comments will remain in the original column, if possible.
# This can be used with unpad-paren to remove unwanted spaces.
#
--pad-header
#
# Remove extra space padding around parenthesis on the inside and outside. Any end of line comments will remain in the original column, if possible.
#
# --unpad-paren
#
# Delete empty lines within a function or method. Empty lines outside of functions or methods are NOT deleted.
# If used with break-blocks or break-blocks=all it will delete all lines EXCEPT the lines added by the break-blocks options.
#
# --delete-empty-lines
#
# Fill empty lines with the white space of the previous line.
#
--fill-empty-lines
#
# Attach a pointer or reference operator (*, &, or ^) to either the variable type (left) or variable name (right), or place it between the type and name (middle).
#
--align-pointer=type
#
# This option will align references separate from pointers. Pointers are not changed by this option.
# If pointers and references are to be aligned the same, use the previous align-pointer option.
#
--align-reference=type
#
# When used with --style=java, --style=kr, --style=stroustrup, --style=linux, or --style=1tbs, this breaks closing headers (e.g. 'else', 'catch', ...)
# from their immediately preceding closing brackets. Closing header brackets are always broken with the other styles.
#
# --break-closing-brackets
#
# Break "else if" header combinations into separate lines.
#
# --break-elseifs
#
# Add brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
# The statement must be on a single line. The brackets will be added according to the currently requested predefined style or bracket type.
# If no style or bracket type is requested the brackets will be attached.
# If --add-one-line-brackets is also used the result will be one line brackets.
#
--add-brackets
#
# Add one line brackets to unbracketed one line conditional statements (e.g. 'if', 'for', 'while'...).
#
# --add-one-line-brackets
#
# Remove brackets from conditional statements (e.g. 'if', 'for', 'while'...).
#
# --remove-brackets
#
# Don't break one-line blocks.
#
# --keep-one-line-blocks
#
# Don't break complex statements and multiple statements residing on a single line.
#
# --keep-one-line-statements
#
# Converts tabs into spaces in the non-indentation part of the line. The number of spaces inserted will maintain the spacing of the tab.
# The current setting for spaces per tab is used. It may not produce the expected results if convert-tabs is used when changing spaces per tab. Tabs are not replaced in quotes.
#
--convert-tabs
#
# Closes whitespace in the angle brackets of template definitions. Closing the ending angle brackets is now allowed by the C++11 standard.
# Be sure your compiler supports this before making the changes.
#
# --close-templates
#
# Remove the preceding '*' in a multi-line comment that begins a line. A trailing '*', if present, is also removed.
#
# --remove-comment-prefix
#
# The option max?code?length will break a line if the code exceeds # characters.
# The valid values are 50 thru 200. Lines without logical conditionals will break on a logical conditional (||, &&, ...), comma, paren, semicolon, or space.
# Some code will not be broken, such as comments, quotes, and arrays. If used with keep?one?line?blocks or add-one-line-brackets the blocks will NOT be broken.
# If used with keep?one?line?statements the statements will be broken at a semicolon if the line goes over the maximum length.
# If there is no available break point within the max code length, the line will be broken at the first available break point after the max code length.
# By default logical conditionals will be placed first on the new line.
# The option break?after?logical will cause the logical conditionals to be placed last on the previous line. This option has no effect without max?code?length.
#
--max-code-length=100
--break-after-logical
#
# Indent a C type, C#, or Java file. C type files are C, C++, C++/CLI, and Objective-C. The option is usually set from the file extension for each file.
#
--mode=c
#
# Verbose display mode. Display optional information, such as release number and statistical data.
#
# --verbose
#
# Force use of the specified line end style. Valid options are windows (CRLF), linux (LF), and macold (CR).
# MacOld style is the format for Mac OS 9 and earlier. OS X uses the Linux style.
# If one of these options is not used the line ends will be determined automatically from the input file.
# When redirection is used on Windows the output will always have Windows line ends. This option will be ignored.
#
--lineend=linux
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment