是否可以在列中使用 clang 格式对齐变量赋值?例如:
int someInteger = 42;
std::string someString = "string";
const unsigned someUnsigned = 42;
#define SOME_INTEGER 42
#define SOME_STRING_LITERAL "string"
#define SOME_CONSTANT 42
enum Enum {
ONE = 1,
TWO = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6,
SEVEN = 7
};
比以下更具可读性:
int someInteger = 42;
const unsigned someUnsigned = 42;
std::string someString = "string";
#define SOME_INTEGER 42
#define SOME_STRING_LITERAL "string"
#define SOME_CONSTANT 42
enum Enum {
ONE = 1,
TWO = 2,
THREE = 3,
FOUR = 4,
FIVE = 5,
SIX = 6,
SEVEN = 7
};
我意识到 clang-format 总是这样做可能不切实际,但是当已经像上述代码一样手动格式化代码时,clang-format 将格式保留在适当的位置会很好。