0
votes

Using some visual studio keyboard shortcuts, I'm trying to highlight a function definition in a more efficient way than "Line Down Extend" Shift+Down Arrow (too many keystrokes).

The closest I can get is highlighting the body with "Goto Brace Extend" Ctrl+Shift+]

enter image description here

However, this omits the function declaration public Function(). If the declaration is first highlighted with Shift+Down Arrow, it becomes un-highlighted when Ctrl+Shift+] is pressed.

1

1 Answers

1
votes

You can use the following command for Visual Commander to select the current function definition:

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;
        ts.MoveToPoint(func.GetStartPoint(EnvDTE.vsCMPart.vsCMPartHeader));
        ts.MoveToPoint(func.GetEndPoint(EnvDTE.vsCMPart.vsCMPartWholeWithAttributes), true);
    }
}