I have a formatting problem in VSCode.
I'm writing a program with many methods in one Class, something like this:
class CPersonalAgenda {
public:
CPersonalAgenda(void);
~CPersonalAgenda(void);
bool add(const string &name,
const string &surname,
const string &email,
unsigned int salary);
bool changeName(const string &email,
const string &newName,
const string &newSurname);
// here is the problem
bool
setSalary(const string &name, const string &surname, unsigned int salary);
// ---
unsigned int getSalary(const string &name, const string &surname) const;
// AND SO ON ...
}
As you can see, one of the methods is being formatted in a way, where there is a newline character added after it.
My formatting settings in C_Cpp: Clang_format_style
in VSC settings are: { BasedOnStyle: LLVM, AlignTrailingComments: true, FixNamespaceComments: false, AccessModifierOffset: -4, IndentWidth: 4, BinPackArguments: false, BinPackParameters: false, AllowAllParametersOfDeclarationOnNextLine: false, ExperimentalAutoDetectBinPacking: false}
Any ideas why this happends? I can't seem to figure out why it would single out only one method.
Look for ColumnLimit
in clang-format --dump-config
. There are must be something like ColumnLimit: 80
.
Either increase the limit
ColumnLimit: 110
Or disable the column limit
ColumnLimit: 0
Or re-word the function declaration
bool setSalary(const std::string &name,
const std::string &surname,
unsigned int salary);
Or set
BinPackParameters: true