As a consultant, I spent most of my time developing with Microsoft technologies for almost 20 years. I have loved Visual Studio (Interdev at one time) as my coding environment. Lately, I have been using a MacBook Pro to do some cross platform development, but never really found anything that fit well for what I was trying to do. Sure, TextMate was probably my best option…I just didn’t spend enough time in it to care to tweak it to my needs.
⌘K ⌘C ⌃⇧Add line comment ⌘K ⌘U Remove line comment ⌘/ ⌃⇧Toggle line comment ⇧⌥A Toggle block comment ⌥Z Editor Toggle word wrap. Other operating systems’ keyboard shortcuts and additional unassigned shortcuts available at aka.ms/vscodekeybindings for macOS. Visual Studio Code – Keyboard Shortcuts on Mac Here’s a list of shortcuts that I found extremely useful when working with Visual Studio Code on Mac. Hope this is useful for people that needs it out there.
In April, Microsoft released Visual Studio Code as part of its //Build conference. I have been using it on my MBP for most of the coding I do on the Mac. I found a number of things I really like…particularly doing Node and JavaScript development. Best part is that it is cross platform, so I can run it on my Mac, Linux and Windows machines, and I have the same editing experience. With Git support built in out of the box, what more could I ask for? Well, here are the things I find save me the most time.
When you are creating a website that is going to be using dynamic content (or just creating a demo), and you don’t quite have access to what that content is yet…what do you do? You fake it. You put in dummy text, and dummy images. Microsoft Word has the feature of using “=rand(10,10)” to generate random content, but that doesn’t help me in my code editor. The focus is on the design, not the content. But running your fingers around on the keyboard for random text is kind of a waste of time and it doesn’t really yield result that shows “for placement only” type look. Besides, you need tags in there to get what you really wanted.
Here’s where Emmet abbreviations come in handy. A simple:
This will get you four paragraphs of random length “lorem ipsum” text. You know good ol’ Lorem right? You can always look here if you need a history lesson on filler texts and the like. This can get more complex by chaining them together. For example:
That will produce five <li> tags with three <paragraph class=”item”> tags containing a random ten word text. Like so:
<pclass='item'>Quas cupiditate eum suscipit magni esse nemo natus quia deleniti?</p>
<li>
<pclass='item'>Lorem ipsum dolor sit amet,consectetur adipisicing elit.Dolores,amet.</p>
<pclass='item'>Officiis consectetur vero numquam quaerat,nam reiciendis enim tempore doloribus.</p>
<pclass='item'>Facere fuga,dolores voluptate labore numquam corporis cupiditate iste accusantium!</p>
<li>
<pclass='item'>Lorem ipsum dolor sit amet,consectetur adipisicing elit.Tenetur,explicabo?</p>
<pclass='item'>Aliquid tempora molestiae dolore,minus nam debitis numquam?Nesciunt,quae?</p>
<pclass='item'>Perspiciatis omnis labore porro et,sit autem architecto non ad.</p>
<li>
<pclass='item'>Lorem ipsum dolor sit amet,consectetur adipisicing elit.Accusantium,tenetur.</p>
<pclass='item'>Ipsum natus,perferendis officiis ex veniam numquam assumenda nesciunt accusamus?</p>
<pclass='item'>Nemo animi molestiae,non facilis corrupti itaque possimus quisquam aspernatur.</p>
<li>
<pclass='item'>Lorem ipsum dolor sit amet,consectetur adipisicing elit.Expedita,cupiditate!</p>
<pclass='item'>Minus iure debitis dicta.Rerum dolore possimus cumque,aconsequatur.</p>
<pclass='item'>Dignissimos enim,corporis.Ex aut fugiat sapiente earum,sint enim.</p>
Visual Studio Zoom Keyboard Shortcut
For more Emmet info, see the documentation here. Sure…this isn’t exclusive to Visual Studio…but I don’t have to do anything to install it and have it working everywhere.
This one is my editing dream come true. When I am refactoring code, I often find that I am adding or removing the same thing in multiple places. No…not duplication like bad code, but adding more descriptive name to items. Maybe it changing a series of properties like HomeAddress, HomeCity, HomeState, HomeZipCode and removing the “Home” piece of this. In the past, the column edit (Alt-shift) was a way to get this done. But now…WHOA! I can click in multiple lines of code in different columns and add or delete code simultaneously. This is done with the Alt-Click in the Code window.
Not only can I do the multi-select with the Alt-Click…I can select all the words that match what I am currently on. In this example, if I wanted to change the word “delorean” I could Ctrl-Shift-L the word and all instances are selected as in the next image.
If the language supports it, hovering over symbols in your code will give you useful information. This really hasn’t been that big of deal for me except for when I am messing with CSS. If you have a lot of complex selectors in your CSS, it is helpful to see how a particular selector is being considered. In Visual Studio Code, I can hover over a selector and see the “hypothetical DOM” that would have this style applied to it. In this case the selector on line 44 would be applied to an element with a class of “sports-icon-list” that contained an anchor tag (<a>) with a heading six (<h6>) applied to it. Very useful to visualize it if I really meant to have a comma in there to apply to more elements.
Visual Studio Keyboard Shortcuts Pdf
So when you work with bracket based languages like C#, Javascript, and C++, you can easily get lost in the mire of missing brackets. For that matter, even if you want to move to the end of the code block, it can be challenging to know you are in the right place. With Bracket Match, you can easily click Ctrl-Shift-] and go directly to the end (or beginning) of a code block. This has saved me an immense amount of time working in my Node applications or messing with Javascript in general. Helpful that it uses the bracket in the keyboard shortcut too.
So I have been used to this in C# for quite some time now, but having it come to Javascript (and other languages). Here’s the cool thing…there are a number of ways to make it work. If you press Ctrl while hovering over a symbol, you will get a quick popup of the definition. A quick click while you are holding the control (Ctrl-Click) and you are now at that point in the code where the symbol was defined or Ctrl-Alt-Click to open the definition in a new side window. Unfortunately, there is no quick way to go back to where you were working, so I prefer the hover or the new side window approach to editing the files.