Avoid formatting code on paste Visual Studio 2015

孤者浪人 提交于 2021-02-07 14:32:23

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!