Find feature in Standard Toolbar Visual Studio 2010, 2012
There is a button ‘Find’ in the Standard toolbar which remains hidden (absolutely no clue why), but adding it can help do some wonders.
In my machine the shortcut for this is Ctrl+D, but I have also seen Ctrl+/ on other machines.
As the name suggests, it helps you to find text in the current file. But did you know you can open files, insert breakpoints and use it as a Command window using this button?
Opening files:
By default, Ctrl+O is the shortcut to pull up the Open Files dialog window.
To use this feature to open files, type a file name in current solution and press Ctrl+O while the focus is still in the Find textbox and the file will be opened for u.
It’s that simple. This is not just limited to the files in the solution, you can open any file on your machine if provide the full path.
Here’s a question you might ask. What if there are multiple files with the same name in my solution? For example, in my test MVC4 solution, there are multiple Index.cshtml files in the Views folder. So what happens if I just search for Index.cshtml? Based on my testing so far, it opens the first file with that name, with the path sorted alphabetically.
If I type Index.cshtml Ctrl+O, it opens the Index.cshtml file in the Gamma folder as it is the first file with that name. If you want to open some other file, you can provide the parent folder name.
And just as usual, if you type in a file name that does not exist, it gives the default 'operation could not be completed’ message.
Inserting breakpoints:
To add a breakpoint, you place the cursor on a line and press the F9 function key. So type in the [ClassName].[MethodName] and press F9 key in the Find textbox and a breakpoint will be inserted at the method declaration.
Just a few points to note here:
1. This is case-sensitive, so if you had typed in homeController.index and pressed the F9 key, the breakpoint will not be inserted.
2. You can only insert breakpoints with this and cannot remove existing ones or the ones you just added.
3. The breakpoint gets added to the method declaration and once debugging begins, the breakpoint is automatically moved to the actual method block.
4. Best of all, you don’t have to have the file open to have the breakpoint inserted.
Command Window:
If you’re not sure what Command window is used for, have a look at the below articles that give a pretty good overview of it’s usage.
http://blogs.msdn.com/b/seealso/archive/2011/01/25/using-the-command-window-in-visual-studio-2010.aspx
http://msdn.microsoft.com/en-us/library/vstudio/c785s0kz.aspx
So, I can just start typing in the Command window and I’ll get intellisense.
In order to convert the Find text box to a Command window, all you have to do is to just type the ‘>’ and then start typing as it is were the Command window itself.
Viola!
Just as an example, you an use the shortcut ‘of’ for open file and you will see the magic happen.
As I started typing the file name, it gave me intellisense options of the possible file names. Just select the one you need and hit Enter and the file opens. Note that this is the Command window now, so you don’t have to do Ctrl+O to open the file.
Go ahead, fiddle around with this great feature, you’ll never know what else you’ll find.
THIS FEATURE IS AVAILABLE IN VISUAL STUDIO 2010 AS WELL.
I also found something with message boxes and although this is completely unrelated to the Find feature, just wanted to share it in this blog itself.
When you get a message box, like the one shown above for ‘operation could not be completed’, press Ctrl+C with the message box as the active window, open any text editor and press Ctrl+V, you’ll see the entire text of the message box.
That’s it for now.