Skip to content

Tip 6.18: How to open a file in the solution without using either a tool window or a dialog box

June 23, 2014

“Visual Studio Tips, 251 ways to improve your Productivity in Visual Studio“, courtesy of ‘Sara Ford’

Sara Ford’s Blog

A 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 …

  1. Press Ctrl+/. This brings you the Find combo box with the “>” already included for you.
  2. Type File.OpenFile . You’ll notice support for autocompletion.
  3. Select a file, and press Enter to open the file.

Because the command File.OpenFile seems to her to be very long to type, you can use the following steps to create an alias that is shorter:

  1. Press Ctrl+/.
  2. 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:

  1. Press Ctrl+/.
  2. Type fo <filename>.

VSTip6118

And now your file is opened in the editor. Tool windows and dialog boxes are not required.

Happy Programming! =)

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: