views:

1106

answers:

8

I have a file a xyz.cpp. I want to open two instances of a this file in Visual studio (btw I am using 2005). Why would I want to do so? I want to compare two sections of the same file side by side. I know workarounds such as

1) make a copy of the file. But the problem is that its not elegant and I dont want to make copies everytime I faced with this.

2) I can split the window into two. The problem with split it than I can split it horizontally only. The result of horizontal split is that right half my screen is white space.

If I were able to split it vertically or open two instances of the same file, it would increase the number of lines of code I can compare.

+1  A: 

Window menu, New Horizontal/Vertical Tab Group there will do, I think.

Anton Gogolev
AFAI see, You can't open the same file in different tab groups
Gishu
VS 2010: this works for me.
quip
A: 

I don't think you can open the same file multiple times in the same instance of Visual Studio and do a side by side compare of different sections of the same file.

  • However you may want to try and open 2 different instances of Visual Studio
  • Open the same file in each. Hit Shift+Alt+Enter to switch to full screen
  • Resize the IDE windows & place them side by side to achieve your layout.
Gishu
A: 

Another work around is to use a compare tool like beyond compare, and compare the same file twice, and then manually force it compare the two area's of code.

But this is not what you want.

What is wrong with the waste white space? collapse all the bottom dock tools, to maximise the vertical space available.

Simeon Pilgrim
+1  A: 

I seem to have achieved this, though I have no idea how (I landed here looking for how I did it). I have two tabs for the same file, labeled with "filename.c:1" and "filename.c:2". I can put them in separate vertical tab groups, so it sounds like exactly what you're trying to do. Anyone know how I accomplished this?

twon33
A: 

I don't have a copy of VS 2005, but this process works on VS 2008:

  1. Open xyz.cpp along with some other file
  2. Right click on tab header and select new vertical tab group
  3. Left click on that other file in the first tab group
  4. Open xyz.cpp through solution explorer again

You should now have 2 instances of file in separate vertical tab groups.

Si
On my VS2K5 and VS2K8 it just shows the original instances in the second tab for me. This is if I double click in Solution Explorer, Drag'n'drop from File Explorer, or via File | Open menu.
Simeon Pilgrim
@Simeon - That happens if there isn't another file open (2nd part of step 1.)
Si
+1  A: 

Open the file (it you are using multiple tab groups, make sure your file is selected).

Menu: Window --> Split (alternately, there's this tiny nub just above the editor's vertical scroll bar - grab it and drag down)

This gives you two (horizontal) views of the same file. Beware that any edit-actions will reflect on both views.

Once you are done, grab the splitter and drag it up all the way (or Menu: Window --> Remove Split)

(Sri: sorry, 'horizontal' as in the views' rows are aligned ... or one view above the other).AFAIK, vertical (side-by-side) views are not possible.
+19  A: 

Here's how to do it ...

  • Select the tab you want two copies of
  • Select Window > New Window from the menu (this will open the same file again in a new tab)
  • Right click the new tab and select 'New Vertical Tab Group'
PaulB
A: 

Side by side comparison suggests to me that you are comparing the different parts of the file because they are nearly identical.

If this is true, I would strongly suggest refactoring your code, placing the very similar functonality into a separate function.

LaustN