2
votes

I'm using prettier + esling in my vscode.

I can't find some settings. I don't know what to descrive so here's some example code.

void set()
{
    ::n = 10;
}

void set() {
    ::n = 10;
} // I prefer this way

and when i'm using namespace in c++

namespace example
{
int n;
void set()
{
    doodle::n = 20;
}
} // namespace example

namespace example
 {
    int n;
    void set()
    {
        doodle::n = 20;
    }
} // namespace example

can you help me with this settings? thanks.

2

2 Answers

1
votes

Press ctrl+P (for MAC use cmd+P) and search for settings.json, and add this line:

"editor.formatOnSave": true

after that, whenever you press ctrl+S for saving, it will format your code.

1
votes

Welcome to Stack Overflow.

Prettier is an "opinionated" formatter, which means that it does not provide many customization settings -- it just formats code the way it thinks code should look.

You may wish to uninstall or disable Prettier, and simply use the formatting settings natively present in VSCode, accessible from preferences.

Or, you can search the VSCode Marketplace for a C++ formatter with more customization options: https://marketplace.visualstudio.com/