If you copy a piece or Razor code into a .cshtml page and you are missing a bracket, or a parenthesis, Visual Studio tries to auto fix and format the document and places new brackets and paranthesis in the wrong spot and breaks the page.
Is there any way to bypass this but still keep the auto formatting that visual studio uses?
Tools -> Options -> Text Editor is where you can configure auto formatting options in Visual Studio.
I understand what you're complaining about and we all experience this from time to time. I don't feel it is a big deal but everyone is different. My 2 cents... Try to be careful and paste proper syntax and code blocks.
I would suspect there is a configuration option in VS that can be set. Bing and Google are you friends you can use to find the
info or post to a VS forum.
If you copy a piece or Razor code into a .cshtml page and you are missing a bracket, or a parenthesis, Visual Studio tries to auto fix and format the document and places new brackets and paranthesis in the wrong spot and breaks the page.
Is there any way to bypass this but still keep the auto formatting that visual studio uses?
after the paste, if you don't like the formatting, you just type ^z (undo) once to undo formatting. a second time to undo paste
Accroding to your description,I'm guessing that you need to turn of auto fix and turn on auto format.
Auto fix:Tools > Options > Text Editor > All Languages > General> Automatic brace completion.
Auto format:Tools > Options > Text Editor > Basic > Advanced.
Best regards,
Yijing Sun
.NET forums are moving to a new home on Microsoft Q&A, we encourage you to go to Microsoft Q&A for .NET for posting new questions and get involved today.
None
0 Points
3 Posts
Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Oct 29, 2020 12:55 PM|seansage|LINK
If you copy a piece or Razor code into a .cshtml page and you are missing a bracket, or a parenthesis, Visual Studio tries to auto fix and format the document and places new brackets and paranthesis in the wrong spot and breaks the page.
Is there any way to bypass this but still keep the auto formatting that visual studio uses?
All-Star
52101 Points
23237 Posts
Re: Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Oct 29, 2020 01:14 PM|mgebhard|LINK
Tools -> Options -> Text Editor is where you can configure auto formatting options in Visual Studio.
I understand what you're complaining about and we all experience this from time to time. I don't feel it is a big deal but everyone is different. My 2 cents... Try to be careful and paste proper syntax and code blocks.
Contributor
4863 Points
4120 Posts
Re: Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Oct 29, 2020 01:19 PM|DA924|LINK
I would suspect there is a configuration option in VS that can be set. Bing and Google are you friends you can use to find the info or post to a VS forum.
https://docs.microsoft.com/en-us/answers/topics/vs-general.html
All-Star
57864 Points
15491 Posts
Re: Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Oct 29, 2020 03:30 PM|bruce (sqlwork.com)|LINK
after the paste, if you don't like the formatting, you just type ^z (undo) once to undo formatting. a second time to undo paste
Contributor
3390 Points
1284 Posts
Re: Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Oct 30, 2020 03:15 AM|yij sun|LINK
Hi seansage,
Accroding to your description,I'm guessing that you need to turn of auto fix and turn on auto format.
Auto fix:Tools > Options > Text Editor > All Languages > General> Automatic brace completion.
Auto format:Tools > Options > Text Editor > Basic > Advanced.
Best regards,
Yijing Sun
Contributor
2590 Points
2661 Posts
Re: Copying and Pasting Razor Page Snippets and AutoFormatting Breaks Page
Nov 06, 2020 05:09 PM|wavemaster|LINK
This has been an issue for years. Microsoft thinks not enough people are impacted so they won't fix it.
Agree with brucesqlwork one (1) undo fixes most of these problems.
It happens all the time, in my case even when I have all matching brackets, prarenthesis.