Reputation: 2227
Is it possible to make the VS Code move the curly brace to the next line automatically?
E.g. in this code:
namespace MyNamesp
{
public class Configuration {
}
}
I would like the code to be formatted like this:
namespace MyNamesp
{
public class Configuration
{
}
}
ASAP as I typed this:
namespace MyNamesp
{
public class Configuration {}
}
And pressed (or not pressed, I do not care about this exactly) the Enter
while being between the {}
.
Right now in order to achieve this kind of formatting I have to select the whole document (Ctrl
+ A
) and click Alt
+ Shift
+ 'F'.
Upvotes: 1
Views: 2949
Reputation: 1
I got same problem, i searched a long for solution, and found C# extension which do this! After a small changes i did same for C++ so:
I hope that it will help someone who will also be looking for.
P.S If you want same for other languages fork and change few lines and you will get same behavior
Upvotes: 0
Reputation: 26936
I think it would help if you turned on the Text Editor settings for Format on Type and Format on Paste. You could also turn on Format on Save if desired.
I would recommend you type in namespace MyNamesp
then press Enter
, then press {
then press Enter
to get what you want. You should not be typing space
after e.g. Configuration
if you want the open brace on a newline, you should be typing Enter
.
Upvotes: 2