question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Visual Studio 2022 formatting issue

See original GitHub issue

Version Used: Visual Studio 2022, 17.40

I’m using C# and have formatting issue since upgrading to 17.40

Expected Behavior: 1.

if () {
if () |{}

press Enter

if () 
|{}

Actual Behavior: 1.

if () {
if () |{ }

press Enter

if () 
    |{ }

This was working as expected in previous version of VS2022, something broke in the newer. I haven’t changed any setting besides turning off the new thing that selects text with the same characters as currently selected. Indenting is set to block, insert spaces, automatically format while typing and on return is turned off. Please help, this is really bothering.

After I complete } space is inserted between {} e.g. if () |{ }`. After I press enter while the caret is located before opened bracket, Actual Behavior step 3. happens.

Issue Analytics

  • State:open
  • Created 10 months ago
  • Reactions:3
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Bgajic-monocommented, Nov 16, 2022

@jasonmalinowski @tmat I rolled back to 17.3.6 and it’s working properly there.

0reactions
tmatcommented, Nov 16, 2022

Indenting is set to block

This makes me think it’s probably the same issue as fixed by https://github.com/dotnet/roslyn/pull/65382.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Microsoft Visual Studio 2022 - Stop All and Any Formatting
Settings > Text Editor > C# > Code Style > Formatting > General: Uncheck "Automatically format on... (all options to disable all).
Read more >
C# editor formatting options - Visual Studio (Windows)
Use the Formatting options page and its subpages (Indentation, New Lines, Spacing, and Wrapping) to set options for formatting code in the code ......
Read more >
Bringing Code Cleanup on Save To Visual Studio 2022 ...
Starting in Visual Studio 2022 17.1 Preview 2, developers can now perform Code Cleanup automatically when a file is being saved!
Read more >
Format on Save for VS2022
Settings in Tools -> Options -> Format on Save. I found it convenient to unify source code format throughout the develop team. If...
Read more >
CSS Error in SCSS File & Formatting Issue (VS 2022)
A fix would be nice] Hi,. I have come across 2 more errors in Visual Studio 2022 (17.2.0) and they are both to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found