Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to suppress auto-indentation in Visual Studio 2022?

Status
Not open for further replies.

IlyaRabyy

Programmer
Nov 9, 2010
568
US
Colleagues,
I was forced to switch to the Visual Studio 2022 at work. And in this version, I can't to figure out how to turn off automatic indentation (did it in VS 2019).
I open a project, made in VS 2019, in VS 2022, copy-pasted some text - and the whole block was indented 3 tabs!
I hit Ctrl+Z to return to the original, then just put cursor on pos. 1 and hit Enter - same thing, indented by 3 tabs!
Here's what it looks like:

Code:
' Before
For I = 1 To liNoOfBundles
   Read_Write_W2XML()
   Me.objProgress.Maximum = liProgressMax
   lnBndlProgress = lnBndlStep * I
   Me.objProgress.Value = lnBndlProgress
   Thread.Sleep(1000)
Next ' I

Placed cursor before the "Read_Write_W2XML()" and hit Enter, and now - this:

Code:
For I = 1 To liNoOfBundles

			Read_Write_W2XML()
			Me.objProgress.Maximum = liProgressMax
   lnBndlProgress = lnBndlStep * I
   Me.objProgress.Value = lnBndlProgress
   Thread.Sleep(1000)
Next ' I

This is despite Indenting is set to None:

2024-01-11_CannotSuppessAutoIndentInVS2022_vuhvkw.jpg


Could you, please, tell me where else I shall look in the "Options" dialog to find how to suppress this automatic indentation in VS 2022?


Regards,

Ilya
 
That’s just a guess, but there may be some hidden characters when you copy the code from VS 2019 and are interpreted differently in VS 2022.
You may try to copy the code, paste it into a Notepad (or Notepad++ to actually see what’s at the beginning of your lines). You may be able to replace those characters with something that VS 2022 understands and treats nice.
:)

---- Andy

"Hmm...they have the internet on computers now"--Homer Simpson
 
Andy, I didn't just "copy the code from VS 2019".
I got my old WS box with Win10 and VS 2019 replaced with box on Win11 and VS 2022, and I copied the project's entire directory via cloud.
Besides, this Auto-Indent does its nasty work even when I hit Enter on a blank line in Editor window: it indents the contents of the entire page when I place cursor at the end of "End Class" statement, see the screenshots:

2024-01-12_UnwantedAutoFormattingInVS2022Win11_kmkunr.jpg


I disabled "Formatting" for any languages in VS 2022, but it didn't help.
And - yes, I copy-pasted this block of code into Notepad++ - no hidden chars were detected.

Any other suggestions, please?

Regards,

Ilya
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top