Is there a way to maintain C++ array formatting when using VScode's default formatter upon saving?

Aiden Rand

When using the default VScode formatter for c++. I want to keep format on save but I don't want the array to be changed this drastically.

It changes an array from this

    const int level[] =
    {
        0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
        0, 1, 1, 1, 1, 1, 1, 0, 0, 0, 0, 2, 0, 0, 0, 0,
        1, 1, 0, 0, 0, 0, 0, 0, 3, 3, 3, 3, 3, 3, 3, 3,
        0, 1, 0, 0, 2, 0, 3, 3, 3, 0, 1, 1, 1, 0, 0, 0,
        0, 1, 1, 0, 3, 3, 3, 0, 0, 0, 1, 1, 1, 2, 0, 0,
        0, 0, 1, 0, 3, 0, 2, 2, 0, 0, 1, 1, 1, 1, 2, 0,
        2, 0, 1, 0, 3, 0, 2, 2, 2, 0, 1, 1, 1, 1, 1, 1,
        0, 0, 1, 0, 3, 2, 2, 2, 0, 0, 0, 0, 1, 1, 1, 1,
    };

to this

    const int level[] = {
        0,
        0,
        0,
        0,
        0,
        0,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        1,
        0,
        1,
        1,
        1,
        1,
        1,
        1,
        ...

    };

I want to keep format on save but I don't want the array to be changed this drastically.

Douglas B

Not sure if you are trying to keep using the default formatting engine for some reason, I can't find an option to change this behavior using the default, but this behavior is not present when setting the option C_Cpp:Formatting (Extensions > C/C++ > Formatting > C_Cpp: Formatting) to vcFormat. If you just want format on save to not elongate your arrays Id use that engine option.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Is a shorter way of saving in a file and formatting the measured real time when using the `time` bash command

Maintain Array of Objects when using product method

XML converts to plaintext when data is pulled using WinForms. Is there a way to maintain the XML, or convert it back in C#?

Any way to maintain a struct array of references to an object? (C++)

What's the default value in an array after using malloc on a struct in C

What is Python's default logging formatter?

How can I print `self` using the Debug formatter in a trait's default method?

C++ What's a way to access an array struct using a function?

Using Mocha Test Explorer with VScode when not in default `/test' folder

Is there a way to use the default Springboot "/actuator/logfile" endpoint when using Logback's RollingFileAppender?

Excel VBA, Keep Formatting when saving as a .txt

Why using validators=[URLValidator] when defining a model CharField doesn't make it check for URL-validity upon saving the corresponding ModelForm?

When is an array automatically initialized to it's default datatype?

VSCode Java Formatter don't linebreak when brackets omitted

Problem when formatting Angular inline template on VSCode

Updating model in UI5, two-way data binding becomes one-way when using formatter

Is there a way to show JavaScript array brackets and the content of an object when using a browser's Developer's Tools?

Only lint typescript when saving file in VSCode

Flutter Provider package reinitializes when saving in VSCode

Using devise_invitable, upon acceptance, saving mutual friendship

Is there a way to maintain ordering with Scala's breakOut?

C - Saving an element to an array

VSCode Formatting

Is it possible to blackbox vendor code when using VSCode's node debugger?

Using java.util.Formatter as default formatter for slf4j

Heap corruption upon using delete[] on an array

How to set default time with date formatter using Swift?

Is there a way to declare a default value when using @ApiQuery with nestJS and swagger?

What's the proper way to call a destructor when you have a two-dimensional array (in C++)?