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+]
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.
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);
}
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.