I am using VS Code as my editor. I have installed the 'EditorConfig for VS Code' extension. I have added an .editorconfig file to my root project. This is the code in the .editorconfig file:
root = true
[*.c]
indent_style = space
indent_size = 4
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = false
insert_final_newline = false
brace_style = attach
The following is the C-file (called main.c) that I want to format by using designated shortcut to apply formatting to the C-file:
#include <stdio.h>
#include <math.h>
double fun(double x, double n)
{
return pow(x, n);
}
int main()
{
printf("Please write a base number:\n");
double base, exponent;
scanf("%lf", &base);
printf("Write a exponent number:\n");
scanf("%lf", &exponent);
printf("The numbers %lf and %lf gives: %lf \n", base, exponent, fun(base, exponent));
}
The C-file (called main.c) is located within the root-folder as .editorconfig file. Thus,
Root
|-- .editorconfig
|-- Project A
|-- main.c
I want to be able to make opening brackets be positioned on same line. The property brace_style should ensure brackets being positioned on same line. Unfortunately they keep being moved to new line. I can change property of indent_size to say 8, and these changes will then be formatted in the main.c file. Thus, there is "connection" between the main.c file and the .editorconfig file. It just don't want to format the brackets to same line.