Visual Studio 2017-是否有键盘快捷键可将整个功能复制到光标下方?

时间:2019-07-18 20:18:21

标签: visual-studio visual-studio-2017

在Visual Studio 2017中是否有键盘快捷键可将整个功能复制到光标下方(未选择)?

1 个答案:

答案 0 :(得分:0)

您可以对Visual Commander使用以下命令,将光标下的整个功能复制到剪贴板,并为其分配键盘快捷键:

public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
    {
        EnvDTE.TextSelection ts = DTE.ActiveDocument.Selection as EnvDTE.TextSelection;
        if (ts == null)
            return;
        EnvDTE.CodeFunction func = ts.ActivePoint.CodeElement[EnvDTE.vsCMElement.vsCMElementFunction] as EnvDTE.CodeFunction;
        if (func == null)
            return;
        System.Windows.Clipboard.SetText(func.GetStartPoint(EnvDTE.vsCMPart.vsCMPartHeader).CreateEditPoint().GetText(func.GetEndPoint(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes)));
    }
}

(类似于Visual Studio 2015 Keyboard Shortcut - Highlight function definition