Display Name
Display Name

Reputation: 15111

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

I often use the following shortcut in Visual Studio 2017 after typing some code.

ctrl+K, ctrl+D          to reformat the alignment

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

ctrl+S                  to save

It will be more convenient if I can create a single shortcut to do all these 3 jobs. Is it possible in VS 2017?

Upvotes: 0

Views: 41

Answers (1)

Sergey Vlasov
Sergey Vlasov

Reputation: 27920

You can call several VS commands from a Visual Commander command and assign a single shortcut to it:

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");
    }
}

Upvotes: 1

Related Questions