Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I force Visual Studio 2008 to use an Open instance when double clicking a file?

Certain non-project files that I use Visual studio for (.build, .xml, free-roaming html and css files) are already associated with visual studio and open in it when i double click them.

How can I get them to open in an existing instance of visual studio? Right now If i double-click the same file twice, it will open two instances of visual studio, I'd like it just to basically ignore the second open attempt if there is already an instance of VS open.

like image 336
Jeff Martin Avatar asked Mar 17 '09 17:03

Jeff Martin


People also ask

How do I change the Open With in Visual Studio?

To change the startup itemOn the menu bar, choose Tools > Options. Expand Environment, and then choose Startup. In the On startup, open list, choose what you want to happen after Visual Studio launches.

How do I split the same file in Visual Studio?

You can open the file in another tab ( Window -> New Window ). Doing so you have two copies of the same file. Then you can right-click the tab bar and select New Vertical Tab Group (or New Horizontal Tab Group , the one you like more). Save this answer.


3 Answers

Windows 7 vs2010 answer;

Because "Default Programs > Associate a file type or protocol with a program" is so useless, use regedit.

Navigate to HKEY_CLASSES_ROOT\VisualStudio.XXX.10.0\shell\Open\Command and add /edit to the end of the open with line, where XXX is the filetype you wish to affect.

Example .reg file for .cpp;

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\VisualStudio.cpp.10.0\shell\Open\Command]
@="\"C:\\Program Files (x86)\\Microsoft Visual Studio 10.0\\Common7\\IDE\\devenv.exe\" /dde /edit"
like image 172
RJFalconer Avatar answered Nov 10 '22 00:11

RJFalconer


Ok Richard helped point me in the right direction a bit, but I think I found exactly what I want.

  1. from an explorer window, go to Tools->Folder Options->File Types tab
  2. find the extension you wish to change.
  3. If there is a restore button click it.
  4. Click Advanced
  5. Click New... to create a new action.
  6. I set the following:

Action: Open in VS 2008
"C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe" /dde
check use dde
DDE Message: Open("%1")
Application: VisualStudio.9.0
DDE Application Not Running: (left blank)
Topic: System

  1. Hit Ok
  2. Set the new action as the default.
  3. Hit Ok, Hit Ok

Now that extension will behave exactly as described in the question. The file will open in an existing VS if visual studio is already open.

I also used this to fix a few extensions that got broken when I reinstalled VS 2005 after 2008.

Win 7/ VS 2012
You can right click a file, go to properties. Then there is an "Opens With" line and a change button. But I don't see a way to force other command line options. VS2012 seems to use the open instance by default.

like image 45
Jeff Martin Avatar answered Nov 10 '22 00:11

Jeff Martin


Which version of VS?

For 2003, there's VSEdit.

In 2005, well, that's the way it works for me out-of-the-box. A quick Google search found something that may help.

Hope that helps.

like image 37
Richard Morgan Avatar answered Nov 09 '22 23:11

Richard Morgan