Welcome to MSDN Blogs Sign in | Join | Help

Sara Ford's Weblog

My adventures embracing open source on CodePlex and at Microsoft

News

    • Did you know... All author proceeds go directly to sending Hurricane Katrina survivors to college.

      Microsoft Visual Studio Tips book

      Recent Entries

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.

Posted: Tuesday, March 04, 2008 3:00 AM by saraford

Comments

Steve Horn said:

You can alternatively use the keyboard shortcut CTRL+ALT+A to pop the command window, and then type "open <filename>".  Auto-complete is provided in this interface as well.

# March 4, 2008 7:50 AM

StevenLJackson1 said:

Hi Sara!  I love this series of posts!  Even though I'm a keyboard junkie, you've actually shown me one or two things that I *didn't* know!  ;-)

Quick question:  I remember from an early version of Visual Studio (or DevStudio as it may have been) when I was doing C++ development that I could highlight a file name (such as in a #include statement), press Ctrl-Alt-G (or something close to that key combination) and have the highlighted file open up in the IDE.

Do you know if that is still an option?  I haven't been able to find it (not sure what the command would be called).  Maybe it's just for C++ developers, so now that I've moved on to C# I don't have that option available to me?

Thanks!

Steve

# March 4, 2008 9:26 AM

small_mountain said:

So why not just:

1.  Ctrl+D (or Ctrl+/ for that matter)

2.  >of <filename>

as suggested in a previous tip (best tip ever, BTW)?

# March 4, 2008 12:00 PM

MarcT said:

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!

# March 4, 2008 12:38 PM

saraford said:

@small mountain:

the difference is that Ctrl+/ will automatically insert the '>' for you in the quick find box.  Ctrl+D will only take you to the quick find box.  So using Ctrl+/ saves you an extra keystroke.  =)

# March 4, 2008 12:46 PM

MarcT said:

@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.

# March 4, 2008 3:09 PM

small_mountain said:

Ahh, I see the ">" now -- well worth it.

Thanks,

Eric

# March 5, 2008 10:57 AM

Darshit Dave said:

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

# March 14, 2008 6:25 AM
New Comments to this post are disabled
Page view tracker