Hello everybody and welcome to this video where I
want to go through some of my favorite things in
Visual Studio 2022. My name is Mads Kristensen and
I work on Visual Studio and I have for the past 12
years and I just want to share some of my favorite
things, because I think that there's something
here that you might not be aware of that will make
you more productive and more happy as a developer
I want to go through a bunch of new features
some updates some tweaks to existing features
that kind of just makes it all feel a lot
better to be a developer when we're using
Visual Studio. But before we dive in where I
want to begin is with the new kind of reality
in the way we work right. A lot of people have
gone back to the offices but a lot of people
have not and then there are people that are
sometimes in the office and sometimes at home
And when we have environments like this
we tend to move between different screen
resolutions and different monitor setups.
So, for instance even though when I'm at
home sometimes I take my laptop out of the
docking station here and I sit in the couch
and I do a little work from there. In that
situation, I just have a small little screen
but when I'm up at my desk like I am here
I have a one of these ultra-wide monitors,
so that's a completely different layout right
and when I go to the office I will I might
have multi-monitors and, so I want to make sure
that no matter where I am where I'm plugged in
what screen setup I've got Visual Studio is
always in an optimal condition to allow me
to do my best work and so let's take a look at
some of the cool things that we can do with that
So, here I have visual studio and you know and
I have my various different windows like the
Toolbox and I have the Solution Explorer out on
the right side here and this works well for this
particular monitor with this resolution that
I'm using right now when I'm sitting with my
laptop I want more of a kind of a minimal layout
like this so in this situation I have a small
screen so I don't want all these tool windows
to show up I need that extra space to code
and I actually also have a kind of a
separate thing is when I work on extensions
I like my layout to be a little bit different
so I write extensions for Visual Studio and
when I do that, I always want like the errorless
to be visible like you see here, and I show a third
tool window over here by the Solution Explorer
but that's only relevant for when I do that
if I work with websites I might have other
requirements different tool windows like the
Task Runner Explorer or other things that I
want to have shown that I otherwise don't
need and then when I'm at my ultra-wide
I really like to spread out horizontally over
that big area and so it will look something
like this now this doesn't look very good
on this monitor and this screen resolution
that I'm using right here but maybe you can get
the idea how I can like spread out horizontally
Let's go back here so let's say you have dual
monitors you could actually take the different
tool windows in Visual Studio and spread
out on these various different monitors
so I don't have that here for this
video so we'll have to pretend
So, let's open a window here. A
tool window - the Test Explorer
and let's imagine that I take this and I drag
that onto my secondary monitor okay and maybe
I'll make it full screen or make it really
big so I can easily see all my unit tests
All I have to do to save that windows layout
so I can easily come back and forth to it
is to go to window it's a save window layout and
then we give it a name let's call it "testing"
and that's it so now I saved this layout
if I go back up to window you can see that
I have all of my saved window layouts
right here and I can apply any of them
For instance, we can go to this one and
then back to the one we just created
"Testing". And I can do that with keyboard
shortcuts to make that very very easy and fast
So, this is super helpful I use this every day all
the time as I move between different development
scenarios but also different monitor setups so I
can't recommend this high enough go check that out
it was a feature we were introducing
in Visual Studio 2019 and we've been
improving it uh as time has gone by so
super life saver for this new world a new
situation with dual monitors and oh sorry
multi-monitors for different locations
All right, so here's another thing. I have my
code base here I got a bunch of files open
but I can't really see how many how many
files do I have open and it you know I don't
really know I can only see what whatever my screen
resolution allows me to see how wide the screen is
and that's why we always have had this
little thing up here you can click next to the
the tabs and if you click that, now notice how
you can see the list of open files
There are some that are grayed out and italics.
Those are the ones that are not visible right now
And then we have the ones that just look
kind of normal. Those are the ones you see
on the screen. And the one in bold
is the one that's currently active
So, that makes it really easy for me to get a
picture of what's open and where can I find things
But you know, sometimes I kind of just want to see
everything all the time all the open documents
So, if I go to the settings icon I can
now click "Show tabs in multiple rows"
and what's really nice here is that if you have
the screen real-estate - if you have the vertical
space, you can now stack all these tabs so you
can see everything that's open. Very very handy
But there are some monitors that are you know
have you know that are extra wide for instance
and in those it would be kind
of nice if we can take our
tabs and instead of having them on top then
move them to the side where we have more space
So again, go into the settings and
click on "Place tabs on the left"
So, it's really nice I can resize
this to whatever. I want to make it fit exactly
my monitor here right so what I'm doing here is
I'm getting that extra vertical space. I can now
see maybe a couple lines more of code in the
editor because I moved the tabs to the side
But let's see what else we can do here because I
have all these open documents and you can see by
default, it's actually kind of nice they are sorted
by the project they belong to, so my solution has
multiple projects and they're all listed under
each of those projects. That's very nice I don't
have to sort that or, sorry, group by project. I
don't have to do any grouping at all, but I really
like that so now it's just alphabetically sorted.
But I want it to be group by project like here
And if we
take it one step further here what if
we colorize these documents per project
So, now each tab has the same color if
it belongs to the same project and that
makes it even easier for me to kind of
at a glance see where these files belong
If we don't want it per project because
I already group my tabs for project here
Instead, we could do it by file extension so
that's also very handy, so I can see all my Razor
files, all my C# files, all my JavaScript
files. They all have a separate color so
it makes it easier for me to get that overview and
that might be exactly what you'd like to do here
And as a new thing we can also go in and
say, let's do it by regular expression and
let's configure the regular expressions. So, it's
a file here that opens up and I can start typing
I'm just going to copy that line up
from above and let's say we want to do
CSS and as soon as I save the file we can see
the CSS file has now got updated with a color
we have Razor I want to have something specific
here and we can even take it further we can say
you know everything that contains the
word um you know category let's say
so like something like this foreign so not all
everything that has the word or c-a-t-e-g will
be colorized so you can do that by folder
you can do that by file name and all these
things so you can really customize how you
colorize these tabs it's pretty phenomenal
And, of course, if you move uh back up and use
the tabs on the top they maintain their colors
so that's really really nice so let's go back
to per project I kind of like to do per project
when I have the tabs up top and that um because in
this case they're not grouped by a project and so
having them colorized by project is my preference
yours might be different but I really enjoy this
So, colors can be very very helpful to us when
it helps us kind of identify the different files
and so on but there's another thing where
I feel a color is a big deal and it has
to do with us sitting in Visual Studio using
visual studio for you know eight hours a day
10 hours a day sometimes five days a week
right. This is this is home away from home
and just like you do with your regular home you
want to have a certain furniture you put in your
house right you have uh what colors do you want
your walls and so on you want to make it yours you
want to make it feel like a place where you're
comfortable and visual studio is no different
so what's really cool now in in Visual Studio
2022 is that we have made it such that you can
take any visuals any Visual Studio Code, VS Code
color theme and convert that to a Visual Studio
color theme very easily and there's a bunch of
these available out on the extension Marketplace
and I want to just show you a few right here so go
to tools theme and you can choose from any of the
themes that you've got installed of course you
get some out of the box with Visual Studio you
can choose from and you can always go
and say click for get more themes and
that will get you to the Marketplace where
you can install all these different themes
and they're fantastic there's so many great
ones in here and they really help us if we
want a nice dark theme if we're sitting in a
dark room for instance and we can even have
Visual Studio changed the theme automatically
when Windows changes its theme there is this
thing here called use system setting and when we
do that if Windows is running in a dark theme at
night for instance after sunset Visual Studio
will automatically switch to the dark theme at
that point in time and back to the light theme at
Sunrise if that's your Windows settings right so
that's really really cool so a whole lot of colors
that makes our lives better in Visual Studio 2022
but let's change that back
to the blue theme for now
and I'm gonna change to a different
project here so here's a just a very simple
.NET console app and I want to show you some
cool things and improvements we've done to the
AI-based coding assistant in in Visual Studio
so I'm gonna type a new line here oh
and notice how Visual Studio automatically
will suggest that I put in a last name which is
exactly what I want in this case I want the last
name property to be inserted for me right here
I also want the full name so let's hit
enter again and this time it suggests age
which is could be could be the accurate one but
I want full name so I'm just going to pretend
it's not showing me anything and just start
typing public string full name and notice here
I can just hit tab and I get my full name and
it understands that full name is a product of
first name and last name this is really really
fantastic so the AI engine here in Visual Studio
understands the context I'm in it understands
that I'm right under the first name property
chances are that I might want another property is
relatively big and based on the name it also then
first name it then also suggests hey the last
name is usually what other people will add when
they you know as the next logical property but
what I was really impressed by was the full name
that it understands what a full name is right
it understands that when people have a first
name and a last name and they need a full name
this is what they want absolutely fantastic here
Let's scroll down and you can see here
I have a method here called remove data
and all it does it removes some data from
the list that I have defined above it
so what's missing here is a method for adding
data so again I'm going to hit enter and
Visual Studio already knows what I'm gonna do
here. I'm going to create an "AddData" method
so notice that based on the name remove data you
know it understands what remove means and add
and so it suggests that I created a method
called "Add" but what was crazy was that it
knew what that would do inside the method
right so it knew that it should not take
the list and remove something it should add to
that list so this is just absolutely fantastic
here I'm just coding by tapping enter and hit
hitting the tab key here it's absolutely great
and we can take it a step further so let's say
that I want to create a new method or I want
some code but I'm not entirely sure how I should
write it what I can do is that I can express it
in a code comment like this one so here I have
a comment it says take the two arguments and add
them together so the args refers to the args
that come into the to the main method up here
so I'm just writing here in plain English what it
is that I would like to have
happen and now I can hit enter
and Visual Studio will automatically
suggest what that code might look like
so it understands what I'm saying in English
in the code comment and can translate that
into something that is might be what I
want so this is absolutely fantastic so
this is the AI engine that is built upon a huge
data set and using machine learning it's able to
take the context that the AI engine is aware of
and pair that up with the big machine learning
model of what do people do in situations like
this that's basically what the machine learning
model knows and when we pair those up together
Visual Studio can do amazing things like this
so um a big step forward for the AI
engine here in Visual Studio 2022
now let's call our new method here the "AddData"
"AddData" and we're just going to give it
some string what are we going to call
it we're going to call it just one
here and I'm gonna just duplicate the
line Ctrl+D duplicates the line like this
and then we can I'm using an extension here called
Shifter that lets me change integers and other
things by keyboard shortcut here Ctrl+Alt+Up/Down
and so now I can fill my list here with data
now let's set a breakpoint and I'm going to
set a specific type of breakpoint this is a
new type of breakpoint temporary breakpoint so
what's really nice about a temporary breakpoint
is that it disappears as soon as the debugger
hits the breakpoint so let's run this console up
so here it runs and it comes down here and you
see the breakpoint is now gone right the break
point is gone because it was temporary it only
hits once so let's stop debugging here and um
let's scroll up so here on line 18 I'm making
a method call into a nougat package called
Newtonsoft JSON and I don't really know what's
going on inside the method called serialize object
I might be able to find the source code
somewhere on GitHub and then go figure it out
but it would be really nice if there's a way for
me to just go straight to the definition hit F12
and go to definition so let's try that and it
takes me straight to the source so this is not
um disassembly or anything like that this is the
actual source code using something called Source
Link all NuGet packages can opt in to Source Link
and that will allow Visual Studio to understand
how to get to the actual source code that made
up this particular version of this NuGet package
and even when you're inside these files you
can keep hitting F12 you know go definition
until we come down here and it's a serialized
object internal and this is a private string
so I'm F12 and I'm going to definition
through a file that made up the NuGet
packets that I'm working on and I can see
everything that's happening super helpful
all right I want to switch over to uh
different project and I'm going to open it
here it's the one I had opened just before
notice how how when I open it up here all the
files that were opened before are now open again
and in my Solution Explorer I can see
that all my folders and projects have
all been expanded to the same levels that
they were last time I used this project
and that's all good that means that I
can get right back into where I left off
but very often this is not what I want very often
I come in I open the project in the morning to
start working on something and I don't want sort
of yesterday's state to be expanded into Visual
Studio I want something clean I want something
fresh I want that fresh car smell in the morning
right I come in I just want none of this open
but I want to be able to open my app and work
with it so I'm going to show you a couple
of settings that are really really helpful
so if you go to Tools > Options and then go to
Projects and Solutions there are two check boxes
that are really good to uncheck here if you're
if you're someone like me that likes that fresh
car smell so "Reopen documents on solution
load" I'm going to uncheck that and "Restore
Solution Explorer project hierarchy state on
solution load" I'm going to uncheck that as well
so now let's go back to the previous
console lab here we can see that
the document was not open and the demo console
project over here is collapsed it's not expanded
so now let's open this project again that
we had before I'm going to switch again
and first of all I don't know if you notice this
but it's instant the loading of these projects
are now instant because no other files have to
be opened no state had to be read from disk and
hydrated into memory and applied on the UI thread
in Visual Studio to expand all the tree notes
in Solution Explorer none of that was necessary
when you open a file let's say you open a C# file
if it's the first time you open a C# file in
that instance of Visual Studio that you've got
open then it has to boot up all of Roslyn and
everything to get IntelliSense and colorization
and all of that working and that's called a
language service and a language service can
sometimes take a little while to load
now it's not necessarily a long time
but it's not instant like it is if we don't
need it and we do like I do here so this is
my default this is what I always do just a little
performance trick if you like the fresh car smell
come on all right I'm going to show you a
one of my favorite new features that we are
putting into Visual Studio this one started its
life as a an extension and it's now coming into
visual studio so let me let me demonstrate
that so let's say I want to add a file to
my project you know I can right click go down to
add and new item and that gives me this dialogue
but what if I go in to Tools > Options
here and click a preview feature flag here
and what I want to search for is here enable
quick add okay so now when I right click and
say add new item or kick Ctrl+Shift+A is the
same thing I get this little dialog up instead
so I can still click on this link that's shown
as well that says show all templates which gives
me that experience that I'm used to but I want to
get the simplified view we call it the quick add
dialog and so in here I can just
type a file name so a name .cs
and that's what it does it just gives
me the internal class and this actually
respects if I have how I how my namespace
rules are in my editor config or in my
settings and it will do the right thing
it uses the templates behind the scenes
but it's a little bit more clever than that so
control shift a again for add new item to bring
it back up let's type something a little bit
more interesting let's what if we create two
files what if I create a Client.cs and IClient.cs
now let's try that I just comma separated them
and I now have those two files but check this
out IClient is an interface whereas Client is a
class so the quick add method or dialog is able
to understand that I client that pattern naming
pattern should match an interface template and
then give me that so that's really really handy
but I can also click create folders so
I'm going to create a folder here called
"folder" and you can name it whatever you want
and just end it with a forward slash hit enter
and now you have an empty folder I could
also have gone in and said okay let's do
what if I do some sub directories here
and then end with a file - file.css
so I can create subfolders I can create
files in those folders again I can comma
separate these to create multiples really
really handy to have all this working
so this is in the preview behind a feature flag
so you saw how I went into Tools > Options under
Preview Features and enabled this feature so I
can't recommend this highly enough I love this
thing I use the extension and for years and
I'm very happy that this is now in the box
So ,now that we have a CSS file open
let's write some CSS. Let's do background
let's do blue and let's do set
index you know three four something
all right so I'm going to show you an extension
here called Shifter it allows me to flip between
values in the editor really really easily let
me demonstrate so I have a keyboard shortcut
here Ctrl+Alt and then either the Up Arrow
or Down Arrow and so if I'm on a number here
like the z-index and hit up Ctrl+Alt+Up it
increments the number like this if it was a
I say 0.08 here you see it will know to keep those
values depending on the decimals and all this sort
of stuff so really really handy if you just need
to like increment by one or something like that
but we can do more it doesn't have
to be just numbers it could also
be colors so here's the color blue so
if I do Ctrl+Alt+Up I get Royal Blue,
Dodger Blue you see here it gets lighter and
lighter the color gets lighter and lighter
and lighter and then it gets darker if I go down
Dark Blue and so on so forth so I can flip through
these very easily I can do the same if if we
have a let's see here let's grab a color here
with the color picker that color right there
so if I have a hex value like this I can do
the same and it understands what hex is and it
knows it's a color in this case and so it will
make the color darker or lighter as I either
go up or down with the keyboard shortcuts
so I'm just going to write some invalid
CSS here we can do other things like
switch between true and
false or you know yes and no
or on off and so on and so forth right so so every
time we can toggle between kind of known values
shifter comes in and makes that super
easy for us Ctrl+Alt+Up and down
so let me pin the upper window here let me build
our project now notice what's going on down here
in the output window I'm
getting a very nice colorized
output here because I'm using an
extension that colorizes everything
which is really nice something is green or gray
means like it's fine there's no no problem but
let's introduce a syntax error let's forget all
right let's delete this semicolon and run again
so now yeah we get an error in the error list
but we also see that our output is now red
because there was an error so it makes
the output window really really easy to
kind of just glance over or skim and
you can see if you have anything red
or anything orange if it's like a warning and
that's just really really helpful so there's
a bunch of these extensions out there that you
can use the one I use is called VSColorOutput,
VSColorOutput so go check that out
really really handy thing to have
and the last extension I want to show you
is compile again is one called
Solution Colors so you may have
the issue where you have multiple instances of
Visual Studio open and how can you tell them
apart they all look the same what if it's the same
repo you have open in both but different branches
now they look almost identical the solution
names are the same all the all the files in
Solution Explorer are the same how do you tell the
difference between open instances of Visual Studio
well what we can do with Solution Color
is that we can right click the solution
and set a color so I can give it any color I
want or I can enable auto mode so auto mode
basically takes the solution path and the branch
name and other things and makes like a unique
color that it will always map to that same color
so if if I now open another Visual Studio here
we can see here it will apply a color as the
solution is low to see this one turns blue
you can see the blue color up here and the other
one got the magenta color or pink right up there
now I can go in here and go to options
and make it a little bit more visible
I can go and say instead of just colorizing
up here the up there and it also puts a line
at the bottom of the screen you know maybe I
want a little bit extra maybe I want it on the
let's hear let's look at the borders instead
of just the bottom what if I wanted at the top
as well so I'm gonna go ahead and do that
and so now I have a thing here at the top
this is very very cool because
now I can very very easily see
that this is the you know I have a
magenta one I have a blue one and so on
and I can even tell by hovering down in the
taskbar those colors are also present here
under each of the thumbnails in the
Windows task bar
and if I don't like magenta I don't
have to have the even though we have
auto mode is on I can always say no
no I want you know give me a burgundy
and I can keep that color and all all other
solutions will still have the automatic one
except for the ones that I manually said hey no
no I want to specify the exact color for this
particular solution and of course I can also hit
the custom one and then select any color you know
RGB color that I can find here so or that that
exists rather so you can be really really specific
here and it stores it um in the .vs folder at the
solution root so it's not something you want to
check into source control you can but it's not by
default so this is just a personal setting to you
having you having put colors on yours does not
change the colors that your team members might
have chosen for theirs or if they don't want
any colors that doesn't make any difference
either because they're kind of
just local to you your machine
so this is called Solution Colors - Solution
Colors so throughout this whole demo you
probably didn't notice because there's no way
to tell that I've been working inside a VM
but not just any VM or virtual machine I've been
working inside a Dev Box a Microsoft Dev Box and
just you can tell there's really no way to tell
this is just Visual Studio running you can run
with any other app that I have installed that
I need to have installed to make my uh make me
able to work on the project I'm working on right
so it's it's just another VM but it's hosted in
the cloud and it's super powerful so if I go to
devbox.microsoft.com this is where I have access
to my Dev Boxes and this is where my it department
has given me the opportunity to create new
Dev Boxes that I can connect to so I have two here
I got Legacy and I got Podcast those are two and
they're pretty powerful uh eight core 32 gigs of
RAM and a terabyte of SSD very fast SSD drives
so depending on your workload you may want
to have a super-fast powerful machine or
if you wanna if you have a lighter
workload you can go sort of smaller
and it's very easy to create a new one so anyone
can just come in here say hey I want to start
on a new project I want a clean machine and you
just set it up very very easily from this website
so it's a very very cool technology it makes sure
that your Windows is always up to date and the
latest patches it's kind of a managed thing
your IT department can manage all these Dev
Boxes the way they can also manage your own you
know physical workstation or laptops um to always
keep them secure compliant up to date connect
them back to your network have all those things
um so that you won't even notice that you're on
a VM and the first time I tried this I was I I
will admit I was a little bit skeptical
but I signed in for the first time and
OneDrive started synchronizing my files so all of
a sudden I had all my files everything was there
all the images and all these different things
that I have on my Desktop and you know in the
My Documents and whatnot it was all there and the
image came pre-installed with Visual Studio and a
bunch of other tools that I needed so I could just
get to work immediately and it really didn't feel
like it was like a a VM that was hosted in the
cloud or anything like that it felt just like
another one of my machines and um I'm very excited
for this I have I have a specific specific use
case uh which is you know Visual Studio sometimes
can use a lot of uh resources when you compile
all the time and run debug and all that sort
of stuff it takes a lot of resources we want
it to take a lot of resources right we wanted to
compile as fast as possible we don't want to sit
and wait so we wanted to use be able to use all
the resources that we've got now the problem with
that is that it for me I have a laptop and it kind
of drains the battery so I can't use Visual Studio
on battery on my laptop for very long but with
Dev Box I can I can go all day long because I
don't do any of that heavy lifting locally on
my laptop it all takes place in the cloud with
much beefier hardware than what I've got in my
laptop so I get a much faster experience and I
get battery that lasts all day it's perfect so is
it public preview you can go ahead and try it out
um I encourage her to do that I think it would
be fantastic and um there's a whole admin story
for your it admin you may want to uh talk to
them about it as well because there's a whole
opportunity for them to make this secure and
compliant and all this sort of stuff making sure
that you don't spin anything up uh that they don't
think you should and um it's so it's a win-win
it's a win for the developer and it's a win for it
you really get that flexibility that productivity
that and get all the hardware you need when you
need it so um go check out Dev Box - Microsoft
Dev Box and that was it for this uh
brief video of me going through some
of my favorite features in Visual Studio 2022
new features are added all the time so make
sure you go check it out uh install the latest
version and try it out for yourself thank you
Wednesday, February 4, 2026
Cool features in Visual Studio 2022
Subscribe to:
Post Comments (Atom)

No comments:
Post a Comment