How to preserve format while pasting in Visual Studio 2015?

You’re experiencing a “feature” of Visual Studio that auto-formats code on certain actions (completed statement on ;, completed block on }, or on Paste. Fortunately, these preferences can be changed via the following settings page (they are language-specific):

VS 2015

Tools > Options > Text Editor > C# > Formatting

Then temporarily uncheck the Automatically format on paste option.

General C# formatting options

VS 2017/2019

In Visual Studio 2017 and 2019, the “Formatting” options moved underneath a new “Code Style” menu and added some extra settings:

enter image description here

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)