Did you know… You can use devenv.exe /edit to open a file in an existing Visual Studio instance – #360


Visual Studio has a command line argument you can specify to open a file in an existing instance of VS.

command line example

Just run devenv /edit <filename> and the file will open in the IDE.

file opened in Visual Studio alongside other files

You could also create a VSEdit command if you find yourself using this feature a lot.  Just create a file called "VSEdit.cmd" (you can use notepad to do this) with the following:

@"devenv.exe" /edit %*

provided you already have %Program Files%\Microsoft Visual Studio 9.0\Common7\IDE added to your system PATH environment variable. And, of course, you might want to place this VSEdit.cmd in a directory that’s in your PATH or add it.

another command line example

Technorati Tags: VS2005Tip,VS2008Tip

Comments (6)

  1. Sara,

    Can you think of a scenario where this would be useful?

    What if I have several VS instances opened? Can I control which instance opens the file? Just curious.

  2. int19h says:

    Isn’t that precisely what it does when you open any file of type associated with Visual Studio in the Shell (Explorer, etc)?

    For me at least, when I double-click a .cs or .cpp file, it seems to open it in a new tab in an existing VS window, if there is one. And it seems to pick the one I used last if there’s more than one open.

  3. Pepe says:

    How is this faster than drag&drop exactly 🙂

  4. VinceG says:

    I think its meant for opening non-VS files such as text files inside VS. I couldnt get it working on my right-click SendTo menu though. Has anyone any ideas on that.

  5. Dennis says:

    To add to the send to menu, create a shortcut with the following target:

    "C:Program FilesMicrosoft Visual Studio 8Common7IDEdevenv.exe" /edit

    or

    "C:Program FilesMicrosoft Visual Studio 9.0Common7IDEdevenv.exe" /edit