Tip 6.18: How to open a file in the solution without using either a tool window or a dialog box
“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’
Sara Ford’s Blog
Sara AsideA blog reader’s question inspired this tip. She receives a lot of e-mail asking her how to do something in Visual Studio. The majority of the questions she doesn’t have the answers to, as they are out of her scope of testing or beyond her experience. So she’s always excited and relieved to see a question that is within her scope, like this one in particular. When she saw the words, “keyboard shortcut” and “open a file,” she knew she could give a meaningful reply. |
The idea here is you just want to press some keyboard shortcut, type the file name that’s in the solution, and go directly to that file. No Solution Explorer. No Open File dialog box. No UI.
Here we go …
- Press Ctrl+/. This brings you the Find combo box with the “>” already included for you.
- Type File.OpenFile. You’ll notice support for autocompletion.
- Select a file, and press Enter to open the file.
Because the command File.OpenFile seems to me to be very long to type, you can use the following steps to create an alias that is shorter:
- Press Ctrl+/.
- Type alias fo File.OpenFile to create a command alias.
Now, for the rest of time or until you reset your command aliases, you can:
- Press Ctrl+/.
- Type fo.
And now your file is opened in the editor. Tool windows and dialog boxes are not required.
Happy Programming! =)