Skip to content

Trying to break 1 line if into 2 lines, and 2 line if / elseif into 4 - nothing is working - c++ #80

@Acecool

Description

@Acecool

I'm working with someone else code and it's quite messy, tabs aren't done properly, etc... I've been playing with the settings but no matter everything I try ( I set keep single-line to false, null, true, along with trying different names but the wiki seems out-dated and doesn't seem to include this ) it continues to keep them in their ugly state...

Basically I want

					if ( rx_buffer[0] & 4 )   report.buttons |= 1;
					else report.buttons &= ~1;

into

					if ( rx_buffer[0] & 4 )
						report.buttons |= 1;
					else
						report.buttons &= ~1;

Additionally, I want to aerate square-brackets but there are no config ooptions... So the above I'd like to appear as:

					if ( rx_buffer[ 0 ] & 4 )
						report.buttons |= 1;
					else
						report.buttons &= ~1;

EDIT: Have to retype because "content changed" blah GitHub....

if preproc cond doesn't indent whats inside, commented or not, which is the selected behavior I have set for these definitions.

There doesn't seem to be anywhere to define having breaks separated by a line or having them in-line with their case rather than indented...

Any help is much appreciated...

				}

				#if BOARD_REV >= 12 /* STM32F042K6T6 */
				// else {
				//  shifter = SHIFTER_NONE;
				// }
				#endif
				break;

Current settings

{



    // Please visit http://astyle.sourceforge.net/astyle.html for more information
    "options_default": {
        // Default bracket style
        // Can be one of "allman" null for default.
        "style": "allman",

        // === Indentation Options ===

        // Indent 'class' and 'struct' blocks so that the blocks 'public:',
        // 'protected:' and 'private:' are indented. The struct blocks are
        // indented only if an access modifier is declared somewhere in the
        // struct. The entire block is indented. This option is effective for C++ files only.
        "indent-classes": true,

        // Indent 'switch' blocks so that the 'case X:' statements are indented
        // in the switch block. The entire case block is indented.
        "indent-switches": true,

        // Add extra indentation to namespace blocks. This option has
        // no effect on Java files.
        "indent-namespaces": true,

        // 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": false,

         "indent-preproc-cond": true,
         "indent-col1-comments": true,
        // 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": true,

        // 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": true,

        // Indent C++ comments beginning in column one. By default C++ comments
        // beginning in column one are not indented. This option will allow the
        // comments to be indented with the code.
        "indent-col1-comments": true,

        // 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 valid values are:
        // 0 - no minimal indent. The lines will be aligned with the paren on the
        //      preceding line.
        // 1 - indent at least one additional indent.
        // 2 - indent at least two additional indents.
        // 3 - indent at least one-half an additional indent. This is intended for
        //      large indents (e.g. 8).
        // The default value is 2, two additional indents.
        "min-conditional-indent": 0,

        // Set the maximum spaces to indent a continuation line.
        // The maximum spaces indicate a number of columns and
        // must not be greater than 120. A maximum of less
        // than two indent lengths will be ignored. This option
        // will prevent continuation lines from extending too
        // far to the right. Setting a larger value will allow
        // the code to be extended further to the right.
        //
        // range: [40, 120]
        "max-instatement-indent": 40,

        // === Padding Options ===

        "pad-comma": true,

        // 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": true,

        // Insert space padding around parenthesis on the inside only. Any
        // end of line comments will remain in the original column, if possible.
        // This can be used with `unpad-paren` below to remove unwanted spaces.
        "pad-paren-in": true,
        "pad-bracket-in": true,

        // Insert space padding after paren headers only (e.g. 'if', 'for',
        //'while'...). 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": true,

        // 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).
        // The spacing between the type and name will be preserved, if possible. To format
        // references separately use the following `align-reference` option.
        // can be one of null, "type", "middle" or "name"
        "align-pointer": "middle",

        // 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. The option align-reference=none will not change
        // the reference alignment. The other options are the same as for `align-pointer`.
        // In the case of a reference to a pointer (*&) with conflicting alignments, the
        // `align-pointer` value will be used.
        // can be one of "none", "type", "middle", "name", or null for default.
        "align-reference": "middle",

        // === Formatting Options ===

        // When `style` is "attach", "linux" or "stroustrup", this breaks closing headers
        // (e.g. 'else', 'catch', ...) from their immediately preceding closing brackets.
        // Closing header brackets are always broken with broken brackets, horstmann
        // rackets, indented blocks, and indented brackets.
        "break-closing-brackets": true,


        // null      - Do nothing
        // "default" - Pad empty lines around header blocks (e.g. 'if',
        //              'for', 'while'...).
        // "all"     - 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": "default",



        // Don't break one-line blocks.
        "keep-one-line-blocks": false,

        // Don't break complex statements and multiple statements residing on a single line.
        "keep-one-line-statements": false,

        //
        "delete-empty-lines": false,
        "break-one-line-headers": true,
        // "break-closing_braces": true,



        // 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": -1,
        "break-after-logical": false,

    },

    //
    // Language Specific Options
    //
    // You can override default options in language-specific options here.
    // Addtional options are also provided:
    //
    // "additional_options": Addtional options following astyle options file style
    //                       (http://astyle.sourceforge.net/astyle.html).
    //                       e.g.: "additional_options": ["--indent=spaces=2", "--convert-tabs"]
    //
    // "additional_options_file": Addtional options file for astyle (aka astylerc), you must specify
    //                            a full path for that file, environment variable may be included.
    //                            e.g.: "additional_options_file": "%USERPROFILE%/astylerc" // (Windows)
    //                            e.g.: "additional_options_file": "$HOME/.astylerc" // (Linux)
    //                            === Additional variables that you may use ===
    //                            $file_path  The directory of the current file, e.g., C:\Files.
    //                            $file   The full path to the current file, e.g., C:\Files\Chapter1.txt.
    //                            $file_name  The name portion of the current file, e.g., Chapter1.txt.
    //                            $file_extension The extension portion of the current file, e.g., txt.
    //                            $file_base_name The name-only portion of the current file, e.g., Document.
    //                            $packages   The full path to the Packages folder.
    //                            The following requires "Sublime Text 3"
    //                            $project    The full path to the current project file.
    //                            $project_path   The directory of the current project file.
    //                            $project_name   The name portion of the current project file.
    //                            $project_extension  The extension portion of the current project file.
    //                            $project_base_name  The name-only portion of the current project file.
    //
    // "use_only_additional_options": While true, SublimeAStyleFormatter will *only* process
    //                                options in *both* "additional_options" and "additional_options_file".


    // Language-specific options for C
    "options_c": {
        "use_only_additional_options": false,
        "additional_options_file": "",
        "additional_options": []
    },

    // Language-specific for C++
    "options_c++": {
        "use_only_additional_options": false,
        "additional_options_file": "",
        "additional_options": []
    },

    // Language-specific for Java
    "options_java": {
        "style": "java",
        "use_only_additional_options": false,
        "additional_options_file": "",
        "additional_options": []
    },

    // Language-specific for C#
    "options_cs": {
        "use_only_additional_options": false,
        "additional_options_file": "",
        "additional_options": []
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions