问题
When I copy and paste the code with Visual Studio, it will auto-format the pasted code (for example, it removes some extra spaces that I have intentionally added for clarity)
I just want that the code is pasted as I copied it, just like a normal text editor does. What I copy it's what I paste :)
Is it possible to just disable the auto-format on paste?
Thanks!
回答1:
Alternatively, to paste text from the clipboard without reformatting applicable to any language, you can use the following C# command with my Visual Commander extension:
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
EnvDTE.TextSelection ts = DTE.ActiveWindow.Selection as EnvDTE.TextSelection;
ts.Insert(System.Windows.Clipboard.GetText());
}
回答2:
You can turn off the Text Editor - C# - Formatting - General - Automatically format on paste option:
来源:https://stackoverflow.com/questions/40341325/avoid-formatting-code-on-paste-visual-studio-2015