避免在粘贴 Visual Studio 2015 时格式化代码 [英] Avoid formatting code on paste Visual Studio 2015

查看:34
本文介绍了避免在粘贴 Visual Studio 2015 时格式化代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我使用 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 时格式化代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆