Visual Studio 2012 New Features: Preview Tab

Tips Search

Visual Studio 2012 New Features: Preview Tab

  • Comments 15

 

Preview Tab Overview

We all explore code and need to move quickly between files when examining code to get familiar with it or debugging or [insert file browsing scenario here]. In prior versions of Visual Studio you had to open a file to look at the contents which often resulted in many open files (tabs) when you were done. The Preview Tab eliminates the need to open files when browsing code. Most likely you’ll first encounter the Preview Tab when you are looking at files with Solution Explorer. When you click on a supported file type, you will see the contents of that file in the new preview tab (to the far right in the tab well):

image

 

If you click anywhere inside the file the tab will go from grey to purple to distinguish it from regular (blue) tabs:

image

 

Again, the point of the preview tab is to let you view the contents of a file without actually opening up a new tab in the tab well. As you look at different files the preview tab only shows the contents of the file you are currently on. This keeps the environment from getting cluttered with open tabs and allows you to focus on only those files that are interesting to you. Solution Explorer isn’t the only place you can use the preview feature. It turns up in several situations where you might need to look at file content. For example, when using Find in Files (CTRL + SHIFT + F) to locate information you will see the preview tab:

image

 

 

Promoting Previews

At some point you may decide to promote the preview to an opened tab in the Tab Well so you can do additional work on the file or just keep it around for other purposes. There are a few ways you can make this happen.

 

Click the Keep Open button

Probably the least useful and and least likely technique you will use is to click on the tiny Keep Open button on the Preview Tab.  It’s not only useless it’s actually kind of annoying for some reason I can’t identify:

image

 

Double Click the File

The most likely approach is you will just double click the file in Solution Explorer or whatever results dialog you happen to be in.

 

Press CTRL + ALT + HOME

With the cursor inside the file (the tab is purple), just press CTRL + ALT + HOME to open a tab for the file you are currently viewing.

 

Change the File

While previewing a file, if you make any change to the file it will automatically be promoted to an open tab so that you can make additional changes and do any other actions you need to perform.

 

Click the Preview Selected Items button

Another button is useless and a waste of space on the Solution Explorer toolbar is the Preview Selected Items button.  You can click it to preview the current file and its only use that I can find is if you turn off single clicking a file to preview it (see below).  Also the tooltip would lead you to believe that you can select multiple files and preview them.  Nope.  Doesn’t work.  Don’t waste your time with this button.

image

 

 

Turning Preview Off

To see the options you have for using the preview feature, just type preview in Quick Launch (CTRL + Q) and click Environment -> Tabs and Windows:

image

 

This will take you to Tools | Options | Environment | Tabs and Windows:

image

 

 

To turn off the preview feature (NOT suggested unless you are having performance issues with it) uncheck the Allow New Files to be Opened in the Preview Tab option. Also notice you can decide if a single click open the files in for preview in Solution Explorer and Find dialogs. For Solution Explorer you can use ALT to prevent a file from being previewed when you click on it. While I see the value in using ALT to prevent preview from happening. I haven’t yet found any reason for turning off the single-click option as it, in effect, forces you to use the Preview Selected Items button which is a lot of extra work and kind of defeats the purpose of the feature.

 

 

Finally

The Preview Tab is one of my top two favorite features in Visual Studio 2012 (the other one being project round-tripping).  You definitely want to leverage this feature to make your life easier.

  • Don't care for this feature a single bit and sorry to say find it rather distracting. I'm glad there is a way to turn it off as I actually went looking for it.

  • Hey SM :)

    I obviously love this feature but can see how it might be a distraction for some folks.  It took me a little while to get used to it but, when I did, I found it indispensable.  

    Z

  • sometimes i click on file to give focus to the solution explorer and it not only previews them, it somehow modifies the files and checks it out of source control.  very annoying.

  • Single click file preview has been one irritating feature (it could just be me!) and I did not like that it was enabled by default. I am glad that I could turn it off.

  • Now that I understand it (thanks to your explanation) I do like it and I am sure I will grow to love it.  Realizing now that double-click works the way it always has makes this feature useful.  Thanks!

  • I just turned this off for fear that I would be using Go To Definition to jump between multiple objects and then lose my place, so to speak.  I noticed that if you jump from A to B to C and then close C, it takes you back to A.  Would be nice if it was a stack and took you back to B.  I like the single click preview, but don't want it if I'm jumping between things.  Any way to do that?

  • Dan,

    Not 100% sure what you are saying.  If you preview a method and then go to definition and do another go to definition on something from there the Preview tab's only job is to show the current file you are in.  It doesn't have any intelligence to remember where you are and if you close it, you have to click on file to get it back.

    In the scenario you described, i would do my Go to Definitions then use Navigate Backward (CTRL + -) to go back the way I came.  The Preview Tab would show the corresponding files that each item was in.  Am I missing something here?

    Z

  • I was searching for a way to disable this annoying feature simply becuase I didn;t understand it and hadn;t connected the dots. Now that Ive found trhis articel that explains what that extyra tab is out to the far right I love it. It definitely reduces clutter, its a great idea.

  • Hey Richard :)

    Glad you like it!

    Z

  • Thanks for the info on how to turn off this terrible anti-feature.  Trying to learn a new codebase is awful when hitting F12 to go to definition doesn't actually open the file, but instead shows a weird read-only right-aligned tab that disappears.

    Turning off this 'feature' has restored my productivity.  Thanks!

  • Phil :)

    Some folks love this feature but it may not be for everyone. If you have an idea for how to make it better I would definitely submit it to visualstudio.uservoice.com

    Z

  • I installed VS 2012 today and found the new feature the most annoying thing in VS 2012. Wonder which PM got a promo for this one?

  • I had to upgrade to 2012, and one of the things I hated most (apart from the disgusting Win8-like skin, yuk) was that while debugging I usually browsed through the code in tabs to the left, and sometimes in this ominous single tab to the right. After finding this article I now finally understand what it is good for, but I still turned it off, since I found it to still be distracting.

    My advice would be to add a msgbox with a "don't show again' button when the tab is used the first time with an explanation why the file is opened in this tab, and what the tabs purpose is. Personally I was totally puzzled by this behaviour, so a quick on-screen explanation would have helped to shed some light on this feature (maybe before I started to hate it, and just had to turn it off :)

  • That's a good idea Roghar. :)

    I'll surface that feedback to the team.

    Z

  • i completely agree with other commenters that this is the single biggest useless and distracting feature of vs2012/2013. It forces users to change their mental model when working in VS, with little benefit.

Page 1 of 1 (15 items)
Leave a Comment
  • Please add 1 and 6 and type the answer here:
  • Post