如何在 VS 2017 中创建由多个快捷方式组成的自定义快捷方式?

How to create a custom shortcut made from several shortcuts in VS 2017?

我经常在 Visual Studio 2017 年输入一些代码后使用以下快捷方式。

ctrl+K, ctrl+D          to reformat the alignment

ctrl+R, ctrl+G          to remove and sort the using directive

ctrl+S                  to save

如果我能创建一个快捷方式来完成所有这 3 个工作,那就更方便了。在 VS 2017 中可以吗?

您可以从一个 Visual Commander 命令调用多个 VS 命令并为其分配一个快捷方式:

public class C : VisualCommanderExt.ICommand
{
    public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package) 
    {
        DTE.ExecuteCommand("Edit.FormatDocument");
        DTE.ExecuteCommand("Edit.RemoveAndSort");
        DTE.ExecuteCommand("File.SaveSelectedItems");
    }
}