Select multiply lines, then type C-u 8 C-x Tab , it will indent the region by 8 spaces.
Now that C++11 is out, I wondered if there are any tips on improving indentation support in Emacs when more and more code is migrated from C++98 to C++11.
Examples:
Here are some questionable indentions that I find myself working around:
struct m {
int a;
char b;
};
std::vector<m> foo { {1, 'a'},
{2, 'b'},
{ 3, 'c'},
{ 4, 'd' }};
I'd prefer
std::vector<m> foo { {1, 'a'},
{2, 'b'},
{ 3, 'c'},
{ 4, 'd' }};
or even
std::vector<m> foo { {1, 'a'},
{2, 'b'},
{ 3, 'c'},
{ 4, 'd' }};
for example.
Next one:
cout << 5
<< [](int a) {
return 2 * a;
} (5);
I'd prefer
cout << 5
<< [](int a) {
return 2 * a;
} (5);
so that the block is indented relative to the lambda.
I find myself spending more time on indentation, which is annoying.
Are any packages or customizations that help to indent modern C++11 code?
(side note: I set up clang-format for Emacs, but I cannot get 100% compatibility which existing code and it also does not yet understand C++11 syntax very well. Still it is useful sometimes and sounds like a good idea for new projects.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With