Did you know... How to open a file in the solution without using either a tool window or a dialog? - #164

Today’s tip was co-authored with a tip of the day reader. 

The idea is you just want to press some keyboard shortcut, type in the filename that’s in the solution, and go directly to that file.  No solution explorer.  No open file dialog. 

Here we go…

  1. Press Ctrl+/ provided you are using the General Development Settings. (If not, follow my instructions on how to find the keyboard shortcuts).  This brings you the Ctrl+D window "command prompt." 
  2. Type File.OpenFile <filename> (you’ll notice support for auto-complete)

Since the "File.OpenFile" felt to me very long to type, you can do the following to create an alias:

  1. Bring up the command prompt – Ctrl+/
  2. Type alias fo File.OpenFile which will create an alias for the rest of time, unless you reset your aliases.
  3. Now you can do
    1. Ctrl+/
    2. fo <filename>

Tool windows and dialogs not required.

Comments

  1.  Ctrl+D (or Ctrl+/ for that matter)
  2.  >of <filename> as suggested in a previous tip (best tip ever, BTW)?
  • Anonymous
    March 04, 2008
    Great tip! If you like this functionality, check out Sonic File Finder http://jens-schaller.de/sonictools/sonicfilefinder/. It's an AddIn that lets you open files by name, but can search within the filename, as well as at the start. And it's free!

  • Anonymous
    March 04, 2008
    The comment has been removed

  • Anonymous
    March 04, 2008
    @StevenLJackson1 Are you looking for Edit.OpenFile, mapped to Ctrl-Shift-G? That's what opens a #included file in VC for me. I don't think any of my C# files have a filename in them so I can't test it there.

  • Anonymous
    March 05, 2008
    Ahh, I see the ">" now -- well worth it. Thanks, Eric

  • Anonymous
    March 13, 2008
    Hi Sara, I created alias 'fo' for File.OpenFile and used it. But, while using 'fo' (alias), the avalialble file list is not shown at the typing file name to open after >fo AddUs..... Is this the so for all or the case only for me? Thanks Darshit Dave