These lines in my .emacs
(setq-default indent-tabs-mode nil)
(setq-default c-default-style "linux")
(setq-default c-basic-offset 4)
result in the following formatting of my c code (the c-basic-offset
of 4
is respected by the style):
int main(
int argc,
char argv
) {
if (1 == 1 &&
2 == 2
) {
return 42;
}
return 0;
}
At the same time, setting the style to "gnu", makes the offsets different (9 and 4 spaces):
int main(
int argc,
char argv
) {
if (1 == 1 &&
2 == 2
) {
return 42;
}
return 0;
}
Why is the same setting treated differently by different styles? Bonus quesition: what do I set up to move the closing ) {
of the function and the if blocks to the left like so:
int main(
int argc,
char argv
) {
if (1 == 1 &&
2 == 2
) {
return 42;
}
return 0;
}
c-basic-offset
differently. ReadC-h v c-style-alist
to acquire an understanding of what different styles can do. – phils Jul 3 '16 at 14:23