 Hello, and we're back. So this is how to be productive developing on a Mac. I'm Kendra Havens. I'm a program manager on .NET. I'm Mikaela Hutchinson. I'm also on the .NET PM team. We have some so cool stuff to get into. Okay. So we don't really have a lot of slides. This is the general idea of what we're going to talk about, but we're mostly going to be geeking out. So I'll go ahead and flip over to my demo app that I'm going to use. If you want to actually follow along with me, you can download this app. So it's on Kendra Havens Mac productivity, or you can go to aka.ms-mac-features-2019, just kidding. Sorry. Mac features 2019. There we go. That'll take you right to a GitHub page that you can go ahead and clone and download. So this app is all of the most recent productivity stuff that we've gotten to Visual Studio Mac. So tons of code fixes and refactorings that we'll talk about and we're also going to just cover the things we most love. Yeah. Should be fun. Yeah. There's lots of super cool stuff that we'll cover. Okay. So now that we've all downloaded some code, we can actually get started. So the first thing I wanted to call out is I'm toggling a line comment that's command slash. So you can put your cursor anywhere on a line, you can also select entire blocks to comment. So command slash and it'll comment the entire block. We didn't have toggle, like it as a toggle command, I think on Visual Studio on Windows, we had control KC and control KV and you had to remember that. But why not just have it be one keyboard shortcut and only use one place in your memory? We're always thinking about optimizing memory. So another one that's really popular is multi-cursor. We have actually had this for over a year probably. Yeah. It came as part of the new editor where we ported the editor from Windows to Mac. So we got a lot of the great features from the Windows version. I didn't realize that's when this came over, that's sweet. So all you need to do is hit control alt click, and you can click in different parts of your IDE. So you can see on my screen, multi-cursor or multi-carat is also what it's called. Yeah. People absolutely love that. We've been able to, let's see, is it alt to drag for a while? So if you wanted to add comments that are all in the same line, here is my comment. You've been able to do that, but actually being able to click around to different places. One thing that I actually just learned we could do, let's see, control alt click. I got to be careful I'm not using the Windows keyboard shortcuts is you can actually go around with arrow keys within your selection, which I did not know you could do. So if I hold down like shift option, and I select more and more, we'll actually stay in line with how many curses that I have, which is super helpful if you're editing a bunch of different lines. Okay. So speaking of like shift selections, you actually taught me this just like last week, which I didn't realize I was doing wrong. So you can, I guess, expand your selection by holding down alt shift and up arrows. If you use the down arrow, it'll go back to your line. So it'll go up to the line that you're on or like more of that actual statement than up to the method body and then the method name and then the whole class within there. Can you keep going and it'll do namespace? Yes, I think so. It's alt shift up. There we go. Then the whole file. Yeah. It's super useful if you want to say extract an expression to a local function or something like that. Oh, sure. Actually, I think I have that. Don't skip ahead on me. Actually, well. It's a good idea. So alt shift and I can select. I meant to just do this code block. So let's say I hit alt enter. I can now extract a single operation to a local function. Very cool. That's only in the preview, right? Yes, only in preview. So this is actually extracting to a local function is an example of one of the code fixes that we most recently got in. So this is only in Visual Studio Update 16.5 preview 2, and it's only in Visual for Mac update. Hold on, 8.4.5 preview. 8.5? Hold on, what do I have installed? 8.5 preview. Sorry, I threw in that four. Take out that four, just 8.5 preview. Pretty sweet. So speaking, I've already listed out lots of different key bindings. So yes, that was a small something of the key bindings, but there's a lot more where that came from. So if we switch over to McKayless machine, we'll see more of how to set your key bindings. So of course, you can find all the key bindings in the menus. But there's a lot of key bindings that you can't actually find in the menus, zoom out. So if you go into preferences, which itself has a key binding which is command comma, you can go into the key bindings panel here, and you can change the key bindings. So if you don't like one of the existing key bindings, you can just go ahead and change that. So if you wanted to add your own key binding for find extension methods, for example, you would just click that, click in edit binding, type something like I don't command shift E, for example, and then apply. Now if you do that, it's going to run the find extension methods command for you. But there's a whole load of commands in here. You can see it's a long list. A lot of them aren't assigned to that key binding column. It's blank. So it's just discovering commands that we've hidden in the IDE that you could actually be using, but they're not even in menus. Yeah. Some of them are in menus, some of them exist and have key bindings, and some of them exist and don't have key bindings. They're all advanced ones, but if you really want to optimize your workflow for those very specific operations, and you can search those of course, like if I wanted to find all the key bindings that affect carrots, for example, you can filter down. It shows you your conflicts if you have commands that conflict with each other. If you just want to make it behave like Visual Studio for Windows, or Xcode, or Ryder, for example, there are built-in schemes that let you automatically switch over to use all the keys from that app. Which I really should be trying out because otherwise my fingers are getting really confused. Yeah. There are a bunch of places where we've tried to make it the same on both Windows and Mac or across, or with Visual Studio Code, for example. But those don't always work together like things collide. They collide with the way that things work on Mac, for example. So we've had to tweak a few things just to make them fit to get into a coherent scheme. So those aren't exactly, but they definitely give you things like a lot more familiar. Definitely. Yeah. So I noticed I'm so jealous of how you can search your key bindings. You can do that in Visual Studio for Mac, but we use some actually odd syntax. Like if you get one character wrong, it's not a very smart, like you can't fuzzy search, you can't add spaces, that kind of thing. There's some really good search experiences in Visual Studio for Mac. Yes. So that's not the only place you can search for commands. You can use the global search up here, which if you ever forget that key binding, it's right there, it's always visible, it's command period. Way to make me feel bad when I forget it. It's kind of gray, so it's kind of faint, you know. Yeah. It's subtle. You can miss it, but yeah. So you just do command period and you can type. So I could type, invert, for example, and we're going to see that here we have a couple of methods found in our solution and it tells us where those were found and you can also use this to kick off a package search. If you want to add a NuGet package, that would actually open the NuGet package manager with that search prefilled out, or you can use that to start a find in files. But you can also use that to search, it doesn't just search for methods, but you can also search for files and for commands. So those commands that you can't access, those commands that you would need to assign a key binding, you can also access them if you just figure out what they're called and just type the name of it. Like for example, show errors here, for example. You click on that, it's going to open the errors pad. So yeah, that's super easy. So you can just do like command period, errors, and then. But if you want to make sure that you're going to get specifically a command because you might have a file called errors, for example, or a type called errors. There are little shortcuts that you can use. So I can do C colon, and that will limit it down to just commands. We can do T colon, and that means just types, or M colon is just members, and F colon is just files. If you forget what those are, you can actually, there's a little menu where that'll actually fill you out with the long form version. You just need the first character, but that's kind of being a bit more explicit. And there are also key bindings that will fill us out for you, like command shift T jumps straight there with type already there. So command shift T, you can go straight searching for types without having to type type. Very nice. So I love how this sort of global search experience has been becoming more and more a thing in the Visual Studio family of products, so yeah. Yeah, one specific thing that I like to do there is to assign a custom key binding. Command shift period to search for commands because that matches the command pallet in VS Code. Oh, nice. Yeah, so exactly. We're kind of stealing from the command pallet in VS Code. I'm actually not sure who had it first. Reading your expression, I bet Visual Studio for Mac had a global search before anybody. No? We've had it for a long time. I don't know who came up with this first. Not to be competitive, but it is actually amazing that in this family of developers, since we're really expanding the diversity of our ecosystem with targeting different operating systems and even working with a ton of different languages that VS Code does, and we can kind of steal the really smart things that we find with all of these new developers coming in and then we get to populate them across our whole family. So global search is one of those. I think a lot of actually toggle line comment was also one of those. I think we at least got it because people used Visual Studio Code and they're like, hey, why don't you just have this toggle experience anymore? And we're like, oh, yeah, that would be smart. We should put it in. And we only had it one way because, hey, that's what was decided a few years ago. And I don't know, it's good to have the new kids on the block telling us to fix their things. Yeah, well, there's kind of cross-pollination in all directions because there's good ideas everywhere. So if we can take all those ideas and bring them together, then we end up with the best experience that we can have. It's beautiful. This is why I like doing talks with Mikaela. She understands me. Okay, so if we switch back over to my machine, I wanted to talk a little bit about our code style and editor severity that we're now completely piping into the Visual Studio for Mac IDE. So you can kind of see I'm getting a suggestion on this variable here. And it's saying, hey, you should be using an explicit type instead of var. Something that we recently added was being able to edit the severity at which code fixes appear and code style violations appear. So if I go into this code style, first I can actually set what I want the style to appear as, but I can also edit the severity and say let's make it a warning instead of a suggestion. Oh, it looks like I'm trying to do a rename operation. That was not intentional. Let's see. Can I save? I'll exit out of a couple of things and reopen. Save. Do, do, do, do. Now it's gonna load. Man, I should have tried this while you were talking. That would have been smarter. Hey, there it is, okay. So I'm still getting the explicit type versus var. And let's see if I can now set the severity to be a warning. Yay, so now I'm getting this green squiggle. So it's basically being able to be a little bit more opinionated about how you customize what code style and how it appears in the IDE. And you might have noticed when I was editing this to reconfigure my code style severity, I was actually, let's see. There, I was getting a preview pane. So this is actually, what is this showing me? This is showing me what lines I'm actually going to be editing in my editor config. So if you all were here with me in the room, this is the time I would ask the audience, how many of you have heard of the editor config? How many of you use it in your team code style to manage per repo code style and suggestions? My show of hands, okay. We should do a poll on Twitter. We should do a poll on Twitter. That would be better for virtual events. So editor config was a tool that existed in the ecosystem apart from .NET for a pretty long time before we adopted it and made our own .NET code style rules using their format. So we did not create another competing stack. We used one that was already there. So it's basically a file to .editor config file that lives at the root of your repo. So it travels along with your source code. It lives with your entire repository and it basically documents all of the code style options that you're using. So if I actually go to my var options, you can see where I've edited it to be warning now instead of what it used to be, which was a suggestion. So this is the thing that is going to be updated whenever I make those changes and edit my severity. And you can apply a bunch of like basic formatting things. And so some code styles, so some things like having your curly brace on the same line or on a new line, you can apply that kind of thing through format document. So format document is a command line tool. Actually, I'll go ahead and show you guys where you can get it. Format document, Visual Studio, GitHub. Let's see if it comes up. Hold on, usually search GitHub and then format document. Wait a second, global tool? Did I misspell something? Oh, there we go. Oh, I should have put .NET format. That's what it is, getting wrong. Sorry, it is called format document in Visual Studio that was built in. And then when we created the global tool, we used .NET format, because .NET is like the command and format would be the verb that you would use in the CLI. So you can install this as a NuGet package. Global tools are basically NuGet packages that you can run as console apps from anywhere in the command line on your computer. So you can quickly, really quickly create .NET tools using this. All you need to do is run .NET tool install, and that'll be .d.NET-format. And a really cool, so I could run this from the command line, but a really cool thing that you can do specifically in VS for Mac is hookup command line arguments or external applications and all kinds of stuff into the menu commands of Visual Studio for Mac. So here I've created a couple format document commands, and I can also pass in even different arguments. So if I only wanted to format on the current file that I'm in, I could choose that command. So it's super easy to do. So I'll go ahead and run a format file, which will only format the open file that I have. And it should be printing to my application output that it's formatting. And when I click back in here, here, why don't I try format document for the whole solution. There we go. So it fixed all of where my curly braces were. Very cool. Pretty sweet. Yeah. So other things that you can hook up in tools, what were we talking about that we loved? You could hook up all sorts of things, like having command line tools is super useful, so you don't have to open a terminal and run those commands. You can pass context like your current file. But you can also use it to open a helper tools. So if you use Git Kraken, for example, or GitHub Desktop for doing your source control, you could put it in that menu so that you don't have to keep it in your doc, or you could launch it from the commands search. So just make that super smooth and integrated into your workflow. Because I think we recommend we use a few different tools. Like I know Azure Data Studio was also one of the ones where we recommend you use those standalone apps as opposed to sort of just supplement your Visual Studio for Mac experience. And if there's already an amazing experience on like GitHub for desktop, then we'll go use those tools. Yeah, pretty sweet. Okay. So one thing I wanted to talk about here was tabs versus spaces and indentation. We were talking about this as we were preparing for this talk, and we just feel like we need to give an update to the community. So it is a very contentious topic. It is a contentious topic. And we'll probably start a flame wall just by having this conversation. That's what I'm here for. So it has been brought, I think it's kind of a growing movement. Developer tools that tabs are way more accessible than spaces. Because people who need to use different fonts, or everything is going to be rendered differently. So as we were talking about Editor-Config, we basically adopted Editor-Config because we felt that CodeStyle needed to be managed per repo. And that was an evolution from our original thought that CodeStyle was managed per individual by like an IDE that applied everything. So we moved from the IDE to an Editor-Config. And now that we're realizing we really need to keep everything accessible to make our community as effective as it can be, and as diverse and welcoming as it can be. Tabs are actually a really good option in a lot of cases for this. So this is one of the few instances that maybe the next step in our evolution, it is going to mean your individual ID will go back to overriding certain aspects of Editor-Config that are better visually for the people using it. Yeah, there's kind of a distinction between the settings that affect the code that you're writing and the settings that affect how that is shown to you. And the settings that affect how that's shown to you should be a personal preference, but you always want the code formatting to be consistent. So other developers work on the same repo, get the same style and you don't end up fighting in merge commits and stuff like that. You kind of think if we had been able to do this from the beginning, like I think we've talked about a long time having source code look one way, but display in a different way, just based on how the person wanted to see it. But like having that visual never is pushed to the repository to be like an ideal, it's been surfaced before. So we're learning. I wonder how many fights we could have avoided. Yeah, well, you can do that with TabWidth. I'm pretty sure right now if you didn't set a TabWidth in your editor config and you set it to use Tab, it would still use your preferences. Oh, nice. It might be wrong, but. I have to double check. Yeah. Sounds really cool. So we're getting there. But yeah, one of the common arguments that we hear for not using Tabs is you can't align things. But the solution to that is surprisingly simple. It's just use both Tabs and spaces. Dun, dun, dun. Gauntlet thrown. So Tabs indentation and then spaces on top of that to align stuff. Yeah, or following it in the column. OK. This is a hill I'll die on. Cool. Anyway, just throwing it out there. Gauntlet thrown. Really cool. OK, so one last thing I wanted to show. Oh, two last things are. Yeah, we're doing good on time. Our file headers. So much of this preparing for this was like, what am I jealous of the VS for Mac that I don't have in VS for Windows every day? And one of them was file header management, which we are working on. And that is, and let's see. I wrote this down. Preferences, source code. There we go. So you can actually choose what file header is automatically inserted at the top when you create a new file. And you actually get a code fix to add this to the top of many of your files. So you can select things. I think I have a custom. Oh, yeah, because we had MIT, but I deleted it because I do not want to include my email or the copyright year. Lach. Anyway, it's really cool that you can apply these. So if I went to the top here and just hit Alt-Enter, I can add my file name. Oh, no, that's not it. Toot, toot, toot, toot, toot, header. Insert standard header. There we go. It's a command. Using that global search sweetness. So that's a really easy way you can add this to a bunch of files, or they'll be added automatically to your templates, which I love. I can't wait to get it. And you can do that on a persolution basis as well, because solutions normally have different requirements for file headers. Right. Pretty cool. OK, very last thing to call out, custom snippets. I am a little bit snippet obsessed. It's fine. I don't have a problem. They're so underused for how useful they are. Let's see, it's an environment. There it is. Sorry, it is in text editor. So you can add all of these custom code snippets into your code, and you can also add ones and completely create one on your own and add different properties with which you can insert them. So earlier with, who was I speaking with? Oh yeah, Dan. We were talking about how to add properties by just typing a name or a tab tab, and it automatically inserts it. And you can see a lot of the snippets that you have in IntelliSense, which is probably more of the editor goodness that we share across our days. Probably, yeah. Pretty cool. Yeah, so a lot of these snippets have short names that you just typed out, then tab tab. But there's a bunch more snippets that don't have those short names that you can access with the insert snippet command. Ooh. Which is in edit. Which I could probably find in. Insert snippet. And that does not have a key binding. Ah, so it's one of those hidden ones that we were talking about earlier. Cool, I'll have to check that out. Mikaela, do you have some favorite features you want to show off? Some favorite features? Yes, yes I do. So if we could switch over to my display. Yes. I can see is editor guidelines your first one? So we're going to go back into preferences. And right now my editor is set up with the default settings. But if you go into the editor settings here, you can see that there's a whole bunch of options. So word wrap, super useful. And show glyphs, so it shows a little marker where a line's been wrapped. I love to turn that one on. There was a good six month period where I thought this is for mac head word wrap and visual studio for Windows didn't. And I was like really better, but then someone showed it to me in Windows. So both have them. Yeah, yeah. Just awesome. Yeah, when features are off by default, for a lot of people they might as well not exist. So yeah, it's, yeah. So hard to choose defaults. We can't please everyone. Yeah, yeah. But yeah, so a lot of these used to be turned off and we turned them on because people just weren't finding them. And they are super useful. So for example, the highlight current line. And you can see here that these actually preview live. Where did the column rule go? I guess some issues with that preview there. But yeah, so the column ruler is super useful. So if your files are set to have a particular length, you can turn on the column ruler, which if your files are set to be say 120 characters wide, that'll show at your 120 characters so that you know that's the size that people who work on your solution are expecting to display it. So you don't create lines that are overly long and they have to scroll sideways. When people are reviewing them, they don't yell at you for not being compliant with their monitor setup, which has happened to me. I was very sad. That's when I cannot wait to get in Visual Studio. We do have a good extension for it though. It's called editor guidelines. And that size is an edge-to-config setting. So it's per repo, profile type. Yeah, another one that's actually off by default that I like to turn on is if we go into markets and rulers, there's show invisible characters. So there's always. And then if I go and reopen my file, I'm not sure where there is an update. You'll see you can see where space is and new lines. And there's little markets, what type of new line. So you can actually see the difference between Windows and Unix new lines there. But I don't personally like that because it's a lot of visual noise. Sure, but as a learning tool, especially for people trying to do formatting, like a white space formatting for the first time and they're writing an automated email or something in their first C-sharp, I was there once and managing that. That'll be so useful. Well, there is a compromise between on and off, which is only show it in, oh, where's my mouse? Not, there we go. Only show it in selection. So only showing it in the selection is super neat. Oh, let's zoom in. Because you don't get that noise the whole time, but then if you want to see what the line endings are in a portion of code, you can just select it. So it gives you a kind of cleaner experience, but you still have that functionality super straightforward to get to. And there's one more thing that I want to show off in preferences, which is namespace policies. So you can be super opinionated with the way that your files directories correspond to the namespaces. So you can choose whether your files namespaces are based on the directory you put them in and you can choose whether that includes the default, the default namespace as the root then adds on the nested folder names or just adds on the directory structure. So cool. Does this change how the test explorer displays namespaces and test grouped by namespace? I don't think it does, no. I just had a quick question coming up for that. Jeff was actually just telling me I need to add like nested namespaces as one of our, how we show things in a directory. And you can also do this per solution as well. So if you go into solution options, which, yeah, or even per project, and you can get to other things like this down at header, you can set per solution right there. So many lovely options to explore. Yep. It's just a smooth experience. Very cool. So it's a good example of how like sometimes, obviously Visual Studio for Mac has developed a lot of features almost like ahead of time, but it's just because you were listening to your developers and what they most needed right away. And that means that what features land in what will be a little bit different. And overall, it's good for us because you get to test new designs and once they're perfect, I get to steal them. So, it's very nice. Yeah. And there's certain things that are kind of expectations on Mac that aren't expected on Windows, but if people really, really like them on Mac and then are also using Windows and sharing their solutions across platforms and they're like, we want it there too. That's really good feedback to have and we can kind of learn from the other platforms. Absolutely. Anything else you want to show off? Extensions? Extensions, yes. Extensions are super cool. There's not as many of them as there are on Windows or on VS Code. But yeah, there's quite a few of them. So there's extensions for things like VIM, key binding support. There's extensions to style your XAML or there's an extension that gives you a PowerShell for packages like you have on Windows. It's not built-in, but you can install the extension and add that. There's also one for MS Build in Telesense, for example. So there's a whole bunch. And yeah, they aren't going to be as good and experienced as the core products, but there's lots of really great functionality hidden out there. Very cool. So the last thing I want to call out is we actually created a new doc just for exploring all of these keyboard shortcuts that we just mentioned. So if we flip on over to my screen, Kendra's screen, Kendra's screen. You can use aka.ms slash vsm-keys and this is actually a PDF. So you can print it out and you can save it wherever you need. It'll be embedded in our docs pretty soon here and it'll list out all of the Visual Studio for Mac keyboard shortcuts as a quick reference. And if that's not good enough, as part of this event, you might have noticed on the corner of our tables, we have these lovely mugs. Upon these mugs are keyboard shortcuts for Visual Studio for Mac. So if you forget what they are and you like hot beverages, you might just have them right in your hands at your fingertips. You'll literally see them every time you take a sip of coffee. Boom. So I was actually giving a talk and I forgot what the toggle line comment was and it is command slash, command forward slash even. So I wish I had had this with me. It really would have saved my butt. There is an easy way to remember that one though, which is the slash is the comment. Yeah. But I don't expect things to be intuitive. No, and most of them are not that memorable to be said. Okay. Well, now that I feel bad about myself. No. Thank you guys so much for joining. I have a quick slide of resources. So you can check out our doc. It's Mac Features 2019. So you can use that productivity features app and you can check out our new Visual Studio for Mac keyboard shortcuts all in PDF form. I guess now we'll go over to questions. Questions. Are there questions? Great session all about key bindings, all about productivity, all about, I love the Macs by the way. I need to have a few. And in fact, if you stay around for the code party, which I will mention a bit, you get a chance to win your own special Mac. Right. So a couple of questions before we announce the party. First of all, can I break a build if the editor config settings are not what they're supposed to be? Like if my team is not abiding to the rules, can we break the build? We can. So the same as on Windows, that'll work if you have your analyzers installed as a NuGet package. It won't work for the ones that are built into the ID itself right now, but we're working on. We're working on having everything built into the IDE delivered as a NuGet package. I wasn't sure. I know you can break your build if you're building via the command line. I wasn't sure if that is the same build that VS for Mac is using ultimately. Yeah, it still goes through the MS-built build engine. So you still get the build output that's screaming, good, good. There you have it. So you can actually enforce your rules. So if you want to have a specific code style for your team and make sure that everyone follows it, editor config is for you. Next one is, what are my theming options for VS for Mac and do you have a favorite? Yeah, I do. So you can theme the entire IDE to use a light theme or dark theme. I usually use dark myself. It doesn't necessarily show up so well on presentation so I switch back. But my favorite part of that is actually a Mac OS system setting, which is if you go into system preferences here, in general, you can set your highlight color. So you can set a little accent color. Oh yeah, the pink. Yeah, and so you'll notice that if you bring up in tell sense that will actually use your accent color. Oh my gosh. So there's a bunch of little places where it just brings your accent color in. So that black and pink, big fan of that. That makes me smile, okay. There's also a whole bunch of editor themes as well. And you can install your own too if you find those elsewhere. And those like live preview so you can see exactly what they look like. I use Solarized Dark for my Notepad++ theme because sometimes you still need Notepad++ for things. Ah yes. Oh man. It's a warm spot in my heart. I am a big fan of Monokai. It's an older theme but still good. Oldie but a goodie. Guess what? I love the pink and the purple and having two girls that I hope and I aspire for them to be developers. It's already set for them. Pink and purple in my ID. One last question. Since I use VS for Mac at home and at work and unfortunately they have two different machines, is there a way for me to sync my settings so I don't have to set them every single time? So there isn't a built-in sync mechanism but you can find those preferences files in your library folder and copy those back and forth. So it's kind of a bit of a secret hack right now but if you set up say OneDrive and then you send link to those to your OneDrive, you could have them directly mirror across. God I love those little hacks. That's amazing, right? Okay, thanks Kendra and Mikayla. That was an amazing session. So many little tips and tricks that you can pick up and know how to make yourself more productive. I want everybody to stay around and in fact you should switch to Tweets because at 2.30 we're actually going to host our code party. We have amazing sponsors that are giving out a ton of free stuff. We have the Macs, we have T-shirts. So stick around and we'll see you very shortly after the break, thank you.