Disable Visual Studio code formatting in Razor

What did the trick for me was pressing CTRL+Z after pasting, then the formatting is removed.


The places to look:

Tools -> Options -> Web Essentials -> HTML -> Auto-format HTML on Enter

(Requires installation of Web Essentials extension)

Set to False

Tools -> Options -> Text Editor -> HTML -> Advanced -> Format on Paste

Set to False

With these settings I have no trouble in Visual Studio 2013.

I used to have to press Ctrl-Z far too often, and if you forgot untangling the mess once your code was written and tested was a huge pain. I feel Microsoft could do alot to help users configure this as well as make it more accessible.


You cannot. This is built in "feature" of VS since the first .net version (visual studio 2002/2003).

There are tons of connect report about the formatting bugs, but Microsoft ignores them completly, or pushing the fix to the "next version". You can see an example Microsoft answer here.

You can post your own feedback to Microsoft Team here


Under Tools -> Options -> Text Editor -> HTML -> Advanced

there is a key value item Paste which says "Format on paste" and has a boolean value next to it. Changing this to false has disabled formatting on paste for me in razor syntax.

I am using VS Professional 2013, Version 12.0.30110.00 Update 1