Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an easy way to jump right to a method within a file?

I just installed Visual Studio 2012 and am having a hard time navigating within a file. What I'd like to be able to do is type in one or more characters of a class, method, field or property within a file and jump right to that line. For example, if I had the code:

public class Foo
{
   public void Bar()
   {

   }
}

I'd like to be be able to hit a keyboard shortcut, type "Ba" and jump right to the Bar method of the Foo class.

In VS2008 and VS2010, I used USysWare's DPack to do this using the Alt + G keyboard shortcut. However, there does not appear to be a version of this plugin for VS2012, at least not yet.

I did find the Ctrl + ; shortcut key to search the solution, which seems to work fairly well for jumping to a specific file (similar to DPack's Alt + U shortcut), however I'm looking for something that will search code within the currently opened file.

BTW, I'm currently using VS2012 Express Edition, but will be upgrading to VS2012 Pro when I have the time to download it and set it up. I believe there's some minor differences between these versions, so I'm interested in answers that apply to either or both.

like image 833
Mike Christensen Avatar asked Oct 30 '12 21:10

Mike Christensen


4 Answers

So here is a summary of what I've found out after some research.

DPack for Visual Studio 2012: Currently, it's in beta but works perfectly fine. Since this is a plugin, it won't run on the Express Edition of Visual Studio.

Ctrl+F: The standard Ctrl+F dialog has been completely re-invented in Visual Studio 2012 and is more of an inline search, jumping around in your document as you type. It's fairly usable for finding symbols, but would also find any matching text in the document, including references, string constants, comments, whatever. For this reason, it's probably not the best way to quickly jump right to a symbol.

Ctrl+Comma: This is also a new VS2012 feature, however it's not available in Visual Studio Express Edition. This allows you to quickly find a symbol within your solution. It works fairly well, though for larger projects it might be information overload.

Ctrl+Semicolon: The Solution Explorer now allows you to filter by filename using the Ctrl+; shortcut key. This makes finding files quick and easy, however will not search symbols within the current file. This is more analogous to DPack's Ctrl+U feature.

Class View Search: Within Class View mode (Ctrl+Shift+C), you can also search for class names or symbols within your entire solution. However, there does not appear to be a keyboard shortcut to use this search, nor can you just search the currently opened file. Also, you have to enter your query and press enter to display the results, rather than just filtering as you type.

Class/Method Dropdowns: Like previous versions of Visual Studio, code files have dropdowns just below the file tabs that display classes and methods within the current file. This is fairly unusable for quickly jumping to any method in the document, as you would first need to select which class the symbol is defined in, and then select the symbol itself. Also, there's no keyboard shortcut that I could find, nor is there an easy way to filter the items in the list by typing part of the symbol name.

like image 195
Mike Christensen Avatar answered Oct 22 '22 03:10

Mike Christensen


You can use Ctrl+, - just type whatever you want in the box and it will find you the corresponding symbols.

like image 40
SomeWittyUsername Avatar answered Oct 22 '22 03:10

SomeWittyUsername


In VS 2017 (not sure, may be also work for some previous versions):

  • Ctrl + T (or Ctrl + ,) to open Go To All window, then
  • Ctrl + Alt + C to enable current document scope. There is an appropriate button in Go To All window that displays document stope is enabled or not.
like image 20
sarh Avatar answered Oct 22 '22 03:10

sarh


I'm using VS Community 2019. I found this combination key:

  • Go to member: Ctrl + 1, Ctrl + M
  • Go to symbol: Ctrl + 1, S
like image 31
peerobo Avatar answered Oct 22 '22 04:10

peerobo