Can I make Visual Studio automatically show corresponding header or implementation file in vertical split? - visual-studio

I'm new to Visual Studio, but have used several other IDE's over the years. I'm stunned by the poor out-of-the-box management of files, filters and "presentation" of coding, and now trying to find if there's a way to customize it the way I've found to be optimal for me.
First off, when programming C++, I'd like for the IDE to use a vertically split automatic view. Dragging and dropping a view to the right side giving me a "static" split is no problem, but that file will stay there untouched until I open another file while in this active view.
What I want is to make it so that when I click a .cpp-file in the explorer, it will show up in the left view - and its corresponding header-file will show in the right view. Likewise, when clicking a header-file, I'd want it to be presented in the right view and the corresponding .cpp-file to show in the left view. If either doesn't exist, just show a blank screen on its side.
When ctrl-clicking a class name, I'd want both the cpp and header-file to be presented, cpp on left and header on right.
Is this not possible?
The second thing that grinds my gears is the solution explorer. I simply don't understand the value of the filter system. I surely do not want every single .cpp file lined up alphabetically under each other, and every single header-file alphabetically another place. I want the explorer to replicate the folder structure as-is. And let me create a file in "src/my_folder/" by right-clicking "my_folder" and add->new item.
I've found that I can click "Switch views" and select "Folder view", but doing this seems to also invalidate the "Solution" and any configurations etc. The solution is literally gone, and the Build/Run-command switches to "Current document" and is completely detached from the project itself.
The closest option I've found is to be in "Solution view" and select "Show all files". The problem is that this shows literally all files and folders, including "output-folders", "hidden" and completely irrelevant files and folders that I don't want here. And I'm naturally not able to "hide" these files, as this is an option to "show all files".
Xcode on Mac has both of these features (and more snacks) pretty flawlessly implemented, and is my all-time favorite IDE per now.
Is there any way to replicate these features in Visual Studio?

Related

How to arrange C++ solution document tabs in pairs of h and cpp?

When I am writing C++ code in Visual Studio 2017 solution view with tabbed documents (which, as far as I can tell, is the standard setting for vcxproj projects after a default installation), I frequently create a mess of 10 or more tabs in opening order. While the tabs' context menu has become quite sophisticated over the years, IMO it lacks some arrangement options, especially one which I miss a lot:
When I have a header file open, I can nicely find the source folder it is located in, by clicking the solution explorer's "sync with active document" arrows icon. I then frequently find myself wanting to open the corresponding cpp file in the vicinity of the h file I just came from. This then opens in a new tab on the far right. Is there a way to force Visual Studio to always arrange corresponding h/cpp tab pairs next to each other? Alphabetically sorting by file name would already do the trick in 99% of cases. The dropdown next to the tabs presents them in that order, why not the tabs themselves?
I looked in the Tools→Options dialog, and into this and this; while similar, not quite what I need.
You can combine h and cpp tabs together and quickly switch between them with my Tabs Studio extension:

Visual Studio View Code on Multiple Files at Once

I'm in the process of migrating some Web Sites to Web Applications, using Visual Studio 2017. One thing I can't seem to figure out is how do I open multiple .cs files at the same time? I can open the .aspx file for them easy enough by right clicking and choosing Open. I can view the code behind on a single page at a time by right clicking and choosing View Code. In the old Web Sites I could right click multiple files at once and select View Code, however, it appears in Web Applications that option has been replaced with "View Code Gen File" which isn't the same thing. It's painfully slow to open a single page at a time so hopefully there is a setting I am just not finding.
EDIT: As requested, uploading screenshots. Only .aspx files are selected but when more than one is selected the "View Source" option is no longer there. Also I should note that if multiple are selected in Solution Explorer, pressing F7 also has no effect, though that keystroke does work to View Source of a single file at a time.
After further experimentation, I now see what you see and I agree that it's something that Microsoft broke along the way. In fact, in your own image, if you single-select an aspx file in Solution Explorer then you can see the "<>" icon appear in the button bar at the top of Solution Explorer. But that icon disappears whenever you select two or more aspx files.
I've done a lot of work with Visual Studio over the years and I can't imagine any justifiable reason why Microsoft would have deliberately removed the View Code option from the context menu for multiply selected aspx files.
This appears to be a bona fide bug that should be reported to Microsoft.
Meanwhile, as a workaround, use the File | Open option in Visual Studio 2017 and, in the resulting Open File dialog box, simply multi-select any .cs files you need (this dialog box allows you to multi-select files and open all of them at once).

How can I, in Visual Studio 2013, get a source control check-in list similar to that in VS2010?

Back in Visual Studio 2010, selecting "Source control" -> "Check in" would open a separate window that listed all checked-out files, with those under the selected node (or the currently open file in the case of going through the File menu) initially selected for checking in. This list was sortable by clicking on the column headers, making it easy to sort the list by any of the fields listed. (Particularly, I found sorting by edit type to be very useful.)
A very similar dialog (actually, I think it is essentially the same one, save for the graphical icons being different to match the revamped UI style) can be accessed in VS2013 through the source control merge wizard by selecting "Selected changesets", right-clicking on a changeset in the resultant list, and choosing "Changeset details". This dialog even has the advanced feature that it is fully resizable according to the preferences of the user and the needs at the time. But that, of course, is only available after the changes have been checked in.
The pending changes/check-in view in VS2013 is just a tree view in the "Pending Changes" window, which can be set to table view but doesn't separate pending change type from file name, making the table view almost, but not entirely, as useless as the corresponding tree view. The view in 2013 also has the serious drawback that while the window (whether docked or free-floating) can be enlarged, I can find no way to enlarge the list of changes vertically, so I am stuck looking at 14 files at a time on the 1920x1200 monitor. While check-ins should generally be small, sometimes check-ins affecting a large number of files are just unavoidable. (Like right now I am looking at a merge affecting a total of 840 files because of a refactoring effort.)
Which leads me to my question. Is there any way to get a dialog similar to that in VS2010 for checking in files when running VS2013?
I'm open to suggestions involving paid-for add-ons, but a free solution (whether it can be done through an add-on, or some configuration setting I have simply failed to find) might be an easier sell.

Can I get VS2010 to look at VSS when I click Open Project?

My VS2010 environment has the start page come up if I'm not opening a solution. From there, I can open one of the several items on the recent projects list or I can open a project from the link/button in the upper left. When I do that, I get an Open Project dialog that's pointed at my C:\workingvss (which is a convention that everyone on my team follows for where our code lives locally). But I virtually always want to browse to the project in a VSS database and I have to scroll up in the left-hand pane of the dialog to bring 'Microsoft Visual SourceSafe' into visibility. It seems dumb that I can't make it just start at the top of the pane, but if there's a way, I haven't been able to figure out how.
So I'm turning to you. Is there something I can do to avoid this click and drag every time I want to open a project?
I realize it's defaulting to the Projects location parameter set through Tools > Options > Projects and Solutions > General. But I think I need to leave that as is because I do want my stuff saved to that location during checkout.
I also think that if I removed ten (in my case) folders from the root of my C:, the left pane would show my VSS option, but I don't think that's even possible in this machine's case and not a reasonable solution in any case.
My question is related to, but not a duplicate of, How to change the default open file dialog path.
Thanks for your time!
This isn't a great answer, but it's my current no-tech work-around. If I make the Open Project dialog large enough to accommodate all of the lines it wants to display, then my VSS line is visible and I don't have to navigate to it. Luckily, Visual Studio remembers the size from use to use.

How can I make the tabs work normally on Xcode 4?

Xcode finally added tabs but the problem is that they behave very strange. For example they will keep a tab open only if it was opened to a new tab.
If you open a file just by clicking in the project tree, Xcode will close your tab as soon as you are clicking on another file in the tree.
Is is possible to make them behave like real tabs and prevent Xcode from reusing them? How?
I use a method similar to franks:
In Preferences > Navigation (or Preferences > General in versions of Xcode prior to 5) you can set Optional Navigation to Uses Separate Tab
Now opt-clicking a file in the file navigator will open it in a new tab
Better yet, opt-clicking links in the code opens the destination file in a new tab
The big feature missing is swapping to an already open tab containing the file if there is one (or staying in the current one).
UPDATE for 2020:
Finally, almost 10 years later, Xcode 12.x now appears to mostly resolve the issue described here. There is a new Navigation Style option in the Navigation settings panel that controls this behavior.
The behavior has some new quirks/design-choices that seem to make sense, but I'm still getting used to the new experience. For example, a tab will get re-used unless the file in that tab has been edited recently; such a tab is indicated with an italics title.
PREVIOUS ANSWER
I don't think you can currently get the behavior you desire (or I desire). While the tabs work like Safari, they don't work like tabs in other popular IDEs (Visual Studio or Eclipse). And for me this kind of sucks.
In general, I expect IDE tabs to keep more than 1 file open. So if I click a file in the project tree, I expect that it will switch to the tab I have opened with that file - if I have already opened it. Instead, XCode 4 changes the current tab to the file I clicked - making 2 tabs with the same file. Having 2 tabs with the same file is fairly useless.
This forces the user to scan the tab bar first to see if the file is currently opened; if it's not opened then you can look to the project tree. But if you click in the project tree first (which is what I tend to do) then you get punished because you will have just killed a tab.
This isn't really an answer insofar as it contains a solution; I mostly just want to join in the griping. But upvoting will make you feel better and prove Apple wrong. :)
The problem with Xcode 4's implementation of tabs is that Apple has implemented them as workspace tabs. In other words, creating a new tab essentially creates a new workspace, each with its own sub-panes with their configurations, etc. It's essentially a whole environment in each tab. There are a number of problems with this choice.
This differs from most IDE/text editors' implementation of file tabs wherein a tab (generally) represents a single file, and each file has its own tab.
The problem with workspace tabs is there are only so many potential different workspaces we could benefit from, severely limiting the actual use of tabs in this way. Beyond this, the additional workspaces just become a liability, introducing more things the user of the application needs to concern him/herself with: for example, what the navigator view is, what editor mode is active (standard, assistant, version), whether the debug console is open, etc. etc. Suddenly switching to a new tab means you now have to worry about getting the environment back in the form you need it, because there's a good chance the other tab wasn't left in the state you expect to find it in. This actually discourages the use of tabs because it introduces more work in the workflow.
File tabs don't have this problem (not counting special cases like split view panes) because all that's changing is the file you're looking at, not your whole environment. Moreover, if implemented properly, file tabs work great as an immediate history, allowing one to quickly switch back to a file that was worked in recently, with little effort. The only way to do this in Xcode is to explicitly set up a new tab environment for each file you want to work with, but you have to be careful not to change the file in that tab or your file all of a sudden becomes lost: again, more work for the user.
Workspace tabs are also significantly heavier-weight than file tabs, because there is much more to remember and switching workspaces involves much more than switching files.
The truth is (and I think most will agree with me on this), to a developer, file tabs are much more useful than workspace tabs, and as it stands Xcode still lacks a proper implementation of this feature that many would consider basic required functionality in an IDE/editor.
Xcode->Preferences->General->Double Click Navigation and from the list, choose Uses Separate Tab.
Well, not a real answer but my personal workaround. The real problem for me is, that a file opened in a tab goes away so easily in xcode 4. Finding a file again can be time-consuming, so I like them to be in a tab and stay there.
I solved this (somehow) for me by exactly identifying the actions I do which cause the tab to switch to another file and replace them by their equivalent actions which open a new tab instead.
Instead of single-clicking a file in the navigator, I always double-click which I have set to open a new tab
Most time I do not use the navigator, as it has a different state of opened and closed folders in each tab. Not useful for me. So I switched to using Option ⌥ Command ⌘ O. When opening a file from this list I keep ShiftOption ⌥ pressed. In the small window appearing I choose 'new tab'.
When clicking on links in code I press ShiftOption ⌥ Command ⌘, too, and open in new tab.
I keep two fixed tabs around for editing target-related settings and to view build results. I completely disabled all automatic tab switching in the prefs, because I noticed this distracted me to much.
I would really love to get something like the xcode 3 favorites bar in xcode 4, this was so simple to use..
I imagine my answer won't bubble up for a while, but if you want this to work like visual studio or intellij (or at least closer)
Preferences->General->Double Click Navigation->Uses a separate tab
Double Clicking a file now will stop opening it in a new window and open it in a new tab.
Single is still dumb and takes over your tab. But if you get used to double clicking (which I was already) this will save you some headaches. I suppose.
I absolutely hate how tabs work in Xcode. However, the only workaround i found that works decent is using the OSX tabs shortcuts:
CTRL + CMD + ->
CTRL + CMD + <-
I found my way in Preferences-Behaviors!
I hated Xcode 4 first for the tab issues discussed here, mainly because the debug information kept opening new files in tabs and changing the navigator
in Behaviors you can define a Debug tab and make the Run and Build jump there in various ways. in the Debug tab I give more space to navigators left and bottom
for similar reasons I have a Find tab, too
the other tabs are for files I am writing in. I start them with the .h which is usually small enough so I need only one view, and then with single clicks in the navegator I open 2-3 versions of the .cpp file so I can set them to the locations where the recent hot spots in the file are. then I close the navigators in those tabs
this does not invalidate the care and tricks given in the other answers here, but makes them far less hard
happy coding!
I found out that when pressing option a.k.a. alt when opening files in the navigator, you will jump to the tab already open with the file and a new tab will open in case it was not yet open.
This technique also works when opening files via cmdshift-O and opening the suggestion with option-enter in stead of simply enter...
Now, if there would be some way to make this the default, i.e. the need to keep pressing option all the time would be removed, that would be a big step forward.
Also I use Behaviors to keep my tabs from being recycled after test or build failures.
(Like other people, I totally mislike Xcode's tab behavior. Apple should take a look at IntelliJ...)
xcode tab bar is so suck, I think Apple should enhance the feature of the tab navigation to avoid followed 3 points.
1. double click a file will let xcode open another tab if it has already been there.
2. for more tabs, the tab will become small and thus I don't know which file in which tab, I want the tab show full name
3. for even more tabs, new tabs will be hidden, instead of two lines of tabs. I want to it show two lines of tab bars.
If you have the tab bar enabled (View/Show Tab Bar) and you double click a file, it appears in it's own window, with a single tab (Be sure the Tab Bar is enabled in both the new and old (main) windows).
Now all you have to do is drag that new window from its tab and drop it into the tab bar of your main window.
It will stay docked as a separate tab, showing that file.
To change the file open in that new tab, go Project / Reveal in Project Navigator, which opens the project navigator at the left hand side.
Tabs in Xcode 4 work like tabs elsewhere on Mac OS X, for example in Safari and Terminal.

Resources