Espressif-IDE clang not formatting indentation when typing
Posted: Thu Jan 09, 2025 12:32 am
I am using Espressif IDE version 3.1.0, and ESP-IDF version 5.3.2.
When I am typing code, it is not indenting the closing braces, or the new line for content, on statements such as 'if' or else': it puts them at the start of the line.
But if I format the document with ctrl-shift-f, it fixes the indentation.
Here is typed code:
Here is after fixing with ctrl-shift-F:
I have the default .clang-format document at the root of my project.
How can I enable the IDE to do the proper indent formatting while typing code?
Thank you
When I am typing code, it is not indenting the closing braces, or the new line for content, on statements such as 'if' or else': it puts them at the start of the line.
But if I format the document with ctrl-shift-f, it fixes the indentation.
Here is typed code:
Code: Select all
static void test_function(void)
{
if (true) {
//this is not indented!
}else {
//this is not indented!
}
if(true){
//I manually indented this and the brace below
} else {
//This is still not indented!
}
}
Code: Select all
static void test_function(void) {
if (true) {
// this is not indented!
} else {
// this is not indented!
}
if (true) {
// I manually indented this and the brace below
} else {
// This is still not indented!
}
}
Code: Select all
# We'll use defaults from the LLVM style, but with some modifications so that it's close to the CDT K&R style.
BasedOnStyle: LLVM
UseTab: Always
IndentWidth: 4
TabWidth: 4
PackConstructorInitializers: NextLineOnly
BreakConstructorInitializers: AfterColon
IndentAccessModifiers: false
AccessModifierOffset: -4
Thank you