问题描述
当我使用 Visual Studio 复制和粘贴代码时,它会自动格式化粘贴的代码(例如,它会删除一些我为清晰起见而有意添加的额外空格)
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?
谢谢!
推荐答案
或者,要从剪贴板粘贴文本而不重新格式化适用于任何语言,您可以将以下 C# 命令与我的 Visual Commander 扩展:
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());
}
这篇关于避免在粘贴 Visual Studio 2015 时格式化代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!