4

In visual studio, we can open a file in a #Include statement by right clicking the filename in include statement and then clicking "Open Document". But sometimes, when I want to open a file, I don't remember where it was in the project or where has it been included. What I do is that I open any file, add a #include statement for that file, then right-click->Open Document to open the file and then remove the #include statement that I added just to open this file.

Can someone plz tell me a more straight forward way of quickly opening a file without searching for it?

I am using Visual Studio 2008

binW
  • 13,220
  • 11
  • 56
  • 69

2 Answers2

5

Hit Ctrl+/ to go to the "Find" combo box in the default toolbar, type >of Foo.cpp , and hit enter. of is the "open file" command and will give you autocompletion with the files in your solution.

This also works for any other system or library header files you include (e.g. windows.h).

enter image description here

The leading > character tells the "Find" combo box to act like the Command Window, so any commands that work in the Command Window work in the combo box as well.

Chris Schmich
  • 29,128
  • 5
  • 77
  • 94
  • This doesnt work for me. There are some header files which are not included in the Visual Studio project but are found in include path. Using "Open Document" I am able to open those header files too but not using this method. – binW Mar 15 '11 at 08:02
  • @binW: you can alternatively try `>Edit.OpenFile foo.cpp`. If that works, you can create an alias for `Edit.OpenFile` with the `alias` command, e.g. `>alias ef Edit.OpenFile` and then `>ef foo.cpp`. – Chris Schmich Mar 15 '11 at 08:11
  • 1
    @binW: also look at the duplicate pointed out by @giddy. If you're using VS2010, you can use Ctrl+, to bring up the "Navigate To" dialog. – Chris Schmich Mar 15 '11 at 08:23
1

Visual Assist X's "Open File in Solution" (command VAssistX.OpenFileInSolutionDialog) works great for quickly opening a file. I find it faster to use than Visual Studio's ">of" command.

See http://www.wholetomato.com/products/featureSearch.asp for a screenshot.

Neil Justice
  • 1,325
  • 2
  • 12
  • 25