Hacking VS Code: Write Your First Extension for Visual Studio Code

All software developers need a robust text editor, like Visual Studio Code, to modify and extend to perfectly meet their specific needs. This course will teach you how extend your text editor to help you become a better developer.
Course info
Rating
(33)
Level
Intermediate
Updated
Jun 10, 2016
Duration
1h 11m
Table of contents
Description
Course info
Rating
(33)
Level
Intermediate
Updated
Jun 10, 2016
Duration
1h 11m
Description

Anyone who writes code will benefit from learning to customize the cross-platform text editor Code. Visual Studio Code from Microsoft gives you lots of options, from simply adding some snippets, to writing and sharing robust extensions that add powerful new functionality. In this course, Hacking VS Code: Write Your First Extension for Visual Studio Code, you'll learn how to build and distribute your first extension. You'll learn to speed your development by creating snippets customized to the file type being edited. Next, you'll add your extension's command to the Code command set and take a look at how to debug an extension. Finally, you'll learn how to use the packaging tool from Microsoft to bundle up your extension, submit it to the marketplace, and then finish by taking a quick look at versioning your extension. When you're finished with this course, you will have a solid understanding of writing extensions using Visual Studio Code, giving you the ability to extend your text editor to perfectly meet your specific needs.

About the author
About the author

Jeff has been passionate about and active in software for over 25 years. Currently he is CEO and Chief Instructor at Code Career Academy (codecareeracademy.com) and runs the Gwinnett Georgia, Microsoft User Group (GGMUG.com). Jeff is a Microsoft MVP in Visual Studio and Development Technologies. He blogs at jeffa.tech. Jeff enjoys speaking to user groups and Code Camps about a variety of technical topics.

More from the author
Section Introduction Transcripts
Section Introduction Transcripts

Introduction
I'm Jeff Ammons of jeffa. tech and codecareeracademy. com. And I'm here to show how to get started hacking VS Code by writing your first extension for Visual Studio Code. Anyone who builds things for a living depends on their tools to help them get the job done. It's also a rare craftsman who can rely on just a single tool. Although I spend most of my in Visual Studio, I always like to keep one or two other tools on hand for specific tasks. No tool is more important for programming than a really good text editor and the ability to modify to suit your needs is critical. In this module, I'm going to walk you through why you shouldn't rely on just one tool, why you should use an editor you can modify and extend, and what kind of problems can extensions solve. In later modules, we'll learn to build and publish extensions to Visual Studio Code. We'll start simple with Snippets instead of a full extension. Then we'll create a hello world extension to see how an extension actually works. After that, we'll create a real world extension that fills a real need. Then finally, we'll learn about distributing our extension. If that sounds interesting, then let's take a look at why you need a tool that you can customize.

Starting Simple
Before we try to build a jet engine, let's start with some simpler options first. In this module we'll take a look at easy ways to customize code without writing an extension. First we'll look at how you can make basic configuration changes like font family and size. Next we'll dive into snippets which will speed your development by popping in boiler plate code. Finally we'll check out an extension that lets you sync your settings, snippets, and even other extensions across computers and even operating systems. That makes sure that wherever you need to work, code will be tailored to your preferences.

Creating a Hello World Extension
Now that we've covered the basics of changing your settings, writing some snippets and syncing across operating systems. Let's dive right in to creating an extension. We'll start slow with the ever popular Hello World. In this module, we'll start by Assembling our Tools and Generating the Skeleton of an extension. Next, we'll take a Tour of the Project structure and look at the important files. After that, we'll try running our extension and make some changes to it. We'll finish up by taking our first look at the debugger, this is going to give us the foundation we need to make a real world extension in the next module. So let's get started.

Building a Real World Extension
In the last module, we built a simple extension divisual studio code that didn't do much. In this module, we'll tackle building a module that solves a real-world problem. First, we going to define the problem we want to solve. Then we'll create our project and add it to GitHub. Next, we'll define the functions we plan to build and set up tracer bullets to highlight the basic pathways we need. Then we'll flesh out our first function, and move on to learning how we can write some unit tests. After that, we'll tackle the second larger function, and finally, we'll learn how to install our extension locally so that we can actually use it.

Distributing Our Extension
In the last module, we created a real world extension to help with writing content for a static website generator. In this module, we'll see how to package it up, and publish it at the official extensions marketplace. You can reach the marketplace from code. visualstudio. com, by clicking the Extensions link. Here we can see lots of extensions, themes, and snippet packs that have been submitted. Let's take a look at what one of the extension pages looks like. Up here we have the banner that includes the name and description, plus the basic installation instructions. Down here, we see the documentation. Over here, we have links back to the support page, license, etc. In the next clip, we're going to download the publishing tool, update our README file, add those links we saw, style our banner, add an icon, and finally publish our extension to the marketplace.