© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•2y ago•
1 reply
Mek

Visual Studio not placing `{}` on new line

internal static bool ValidatePassword(string password) 
{
    if (string.IsNullOrEmpty(password) || string.IsNullOrWhiteSpace(password))
    {
        return false;
    }

    return Regex.IsMatch(password, PasswordRegex);
}

internal static bool ValidateName(string name) {
    if (string.IsNullOrEmpty(username) || string.IsNullOrWhiteSpace(username)) {
        return false;
    }
    return Regex.IsMatch(name, NameRegex);
}
internal static bool ValidatePassword(string password) 
{
    if (string.IsNullOrEmpty(password) || string.IsNullOrWhiteSpace(password))
    {
        return false;
    }

    return Regex.IsMatch(password, PasswordRegex);
}

internal static bool ValidateName(string name) {
    if (string.IsNullOrEmpty(username) || string.IsNullOrWhiteSpace(username)) {
        return false;
    }
    return Regex.IsMatch(name, NameRegex);
}
when I create a new class, function, if/else statement, try/catch/finally clause, etc and I type it out
internal static void MyFunction() {
internal static void MyFunction() {
and I press Enter on that beginning
{
{
or I do it with the other items I listed, Visual Studio does not place the
{ }
{ }
on a new line as shown above. In the above code, the
ValidatePassword
ValidatePassword
function is the way I want it to be and the function
ValidateName
ValidateName
is how Visual Studio 2022 current does it and I have to manually fix it every time. In the screenshot you can see I have all the settings turned on that the couple of StackOverflow post answers have mentioned, but nothing is working. I've also tried unchecking every box, reloading the editor, trying it out, checking them all back, reloading editor, and trying it out again, and it still doesn't do anything. Thanks in advance
image.png
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

✅ Disabling new Visual Studio tips
C#CC# / help
4y ago
Visual Studio on Mac
C#CC# / help
15mo ago
Visual Studio vs Visual Studio Code?
C#CC# / help
3y ago