No automatic indentation when entering parentheses ({) and line breaks in Visual Studio 2017

Asked 2 years ago, Updated 2 years ago, 70 views

In Visual Studio 2017, after parentheses are complemented, line breaks do not insert indentation.
What should I do?

In my environment, entering the parentheses automatically complements the cursor position as shown below.
(| represents the cursor)

 if(a=="a"){|}

If you press Enter in this state,

 if(a=="a"){
|}

That's what happens.

This is

 if(a=="a"){
    |
}

What should I do if I want to have indentation automatically when I break a new line like this?

By the way, the indentation width is 4 spaces.
The language is expected to be C/C++

windows visual-studio

2022-09-30 21:33

1 Answers

In our environment
on the options screen Select the Text Editor > C#> tab and click
·Indent: Smart
The behavior was expected when you set it to .

However, if you don't add a new line immediately after the parentheses are automatically supplemented,

 if(a=="a"){
|}

It looks like this.


2022-09-30 21:33

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.