Visual Studio Code is not just another evolved notepad with syntax colorization and automatic indentation. Instead, it is a very powerful code-focused development environment expressly designed to make it easier to write web, mobile, and cloud applications using languages that are available to different development platforms and to support the application development lifecycle with a built-in debugger and with integrated support to the popular Git version control engine.
With Visual Studio Code, you can work with individual code files or with structured file systems based on folders. This chapter provides an introduction to Visual Studio Code giving you information on when and why you should use it, as well as about installing and configuring the program on the different supported operating systems.
Note
Across the book, I will refer to the product with its full name, Visual Studio Code, and its friendly names VS Code and Code interchangeably.
Introducing Visual Studio Code
Visual Studio Code has been the first cross-platform development tool in the Microsoft Visual Studio family that runs on Windows, Linux, and macOS. It is free, open source ( https://github.com/Microsoft/vscode ), and it is definitely a code-centric tool, which makes it easier to edit code files and folder-based project systems as well as writing cross-platform web and mobile applications over the most popular platforms, such as Node.js and .NET Core, with integrated support for a huge number of languages and rich editing features such as IntelliSense, finding symbol references, quickly reaching a type definition, and much more.
Visual Studio Code is based on Electron ( https://electronjs.org/ ), a framework for creating cross-platform applications with native technologies, and combines the simplicity of a powerful code editor with the tools a developer needs to support the application lifecycle development, including debuggers and version control integration based on Git. It is therefore a complete development tool, rather than being a simple code editor. For more advanced coding and development, you will certainly consider Microsoft Visual Studio 2017 on Windows and Visual Studio for Mac on macOS, but Visual Studio Code can be really helpful in many situations.
In this book, you learn how to use Visual Studio Code and how to get the most out of it, seeing how you can use it both as a powerful code editor and as a complete environment for end-to-end development. Except where necessary, figures are based on the Microsoft Windows 10 operating system, but there is no difference on Linux and macOS. Also, Visual Studio Code includes a number of color themes that style its layout. In this book, figures are based on the so-called Visual Studio Light Theme, so you might see different colors. Chapter 5, “Customizing Visual Studio Code,” explains how to change the theme, but if you want to be consistent with the book’s figures, simply select File ➤ Preferences ➤ Color Theme and select the Visual Studio Light Theme. It is worth mentioning that the theme you select does not affect at all the features described in this book.
When and Why Visual Studio Code
Before you learn how to use Visual Studio Code, what features it offers, and how it provides an improved code editing experience, you have to clearly understand its purpose. Visual Studio Code is not a simple code editor; rather it is a powerful environment that puts writing code at its center. The main purpose of Visual Studio Code is making it easier to write code for web, mobile, and cloud platforms for any developers working on different operating systems, such as Windows, Linux, and macOS, making you independent from proprietary development environments.
Built-in support for coding with many languages, including those you typically use in cross-platform development scenarios, with advanced editing features and support for additional languages via extensibility
Built-in debugger for Node.js, with support for additional debuggers (such as .NET Core and Mono) via extensibility
Version control based on the popular Git engine, which provides an integrated experience for collaboration supporting code commits and branches, and that is the proper choice for a tool intended to work with possibly any language
Visual Studio Code can produce binaries and executable files only if the language you use has support to do so through a debugger. If you use a language for which there is no extensive support (e.g., Visual Basic), Visual Studio Code is not able to invoke a compiler. You can workaround this by implementing task automation, discussed in Chapter 8, "Automating Tasks," but this is different than having the compilation process integrated.
Visual Studio Code has no designers, so creating an application’s user interface can only be done by writing all of the related code manually. As you can imagine, this is fine with some languages and for some scenarios, but it can be very complicated with some kinds of applications and development platforms, especially if you are used to work with the powerful graphical tools available in Microsoft Visual Studio.
It is a general purpose tool and is not the proper choice for specific development scenarios such as building Windows desktop applications.
If your requirements are different, consider instead Microsoft Visual Studio 2017 or Microsoft Visual Studio for Mac, which are optimized for building, testing, deploying, and maintaining multiple types of applications.
Now that you have a cleaner idea of Code’s goals, you are ready to learn the amazing editing features that put it on the top of any other code editor.
Installing and Configuring Visual Studio Code

The download page for Visual Studio Code
In the next paragraphs, you will learn tips for installing Code on the various supported systems.
Note
The latest stable release at the time of this writing is version 1.27.2, released in August 2018 and called August Recovery.
Installing Visual Studio Code on Windows
Visual Studio Code can be installed on Windows 7, 8, and 10. For this operating system, Visual Studio Code is available with two installers: a global installer and a user-level installer. The first installer requires administrative privileges for installation and makes Code available to all users. The second installer makes Code available only to the currently logged user, but it does not require administrative privileges.
The latter is the choice I recommend, especially if you work within a corporate environment and you do not have administrative privileges to install software on your PC. The Download for Windows button that you can see in Figure 1-1 will automatically download the global installer. If you instead wish to download the user-level installer, click the arrow at the right of the button and then click the User Installer hyperlink. It is worth mentioning that Visual Studio Code is available in two versions, 32 bit and 64 bit. The download page will automatically suggest the version that matches your operating system architecture, but if you wish to download a different installer, you can click the arrow and then click Other downloads.
Add “Open With Code” action to Windows Explorer file context menu, which allows for right-clicking a code file in the Explorer and opening such a file with VS Code.
Add “Open With Code” action to Windows Explorer directory context menu, which allows for right-clicking a folder in the Explorer and opening such a folder with VS Code.
Add to PATH (available after restart), which adds the VS Code’s pathname to the PATH environment variable, making it easy to run Visual Studio Code from the command line without typing the full path.
Note
Some antivirus and system protection tools, such as Symantec Endpoint Protection, might block the installation of some files that are recognized as false positives. In most cases this will not prevent Visual Studio Code from working, but it is recommended that you disable the protection tool before installing Code or, if you do not have elevated permissions, that you ask your administrator to do it for you.

Visual Studio Code running on Windows
Installing Visual Studio Code on macOS

Visual Studio Code running on macOS
Installing Visual Studio Code on Linux
Linux is a very popular operating system and many derived distributions exist, so there are different installers available depending on the distribution you are using. For the Ubuntu and Debian distributions, you will need the .deb installer. For the Red Hat Linux, Fedora, and SUSE distributions, you will need the .rpm installer. This clarification is important because, differently from Windows and macOS, the browser might not be able to automatically detect the Linux distribution you are using, and therefore it will offer both options.

Visual Studio Code running on Ubuntu
Note
If you are a Windows user and want to try Visual Studio Code on a Linux distribution, you can create a virtual machine with the Hyper-V tool. For example, you might install the latest Ubuntu version ( www.ubuntu.com/download/desktop ) as an ISO image and use it as an installation media in Hyper-V. On macOS, you need to purchase the Apple Parallels Desktop software separately in order to create virtual machines, but you can basically do the same.
Localization Support
Visual Studio Code ships in English, but it can be localized in many other supported languages and cultures. When started, VS Code checks for the operating system language and, if different from English, it shows a popup suggesting to install a language pack for the culture of your operating system. The localization support can be also enabled manually.
This will open a file called locale.json, which is the place where Visual Studio Code stores the localization information. Figure 1-5 shows how this file appears in the editor. As you can see in the comments, there is a link to the documentation that contains the full list of supported cultures.
Note
The Command Palette will be discussed thoroughly in the next chapter.

Changing the localization for Visual Studio Code
For instance, if you wanted to change the localization from English to Italian, you would replace en with it, saving your changes. At restart, Visual Studio Code will apply the new localization downloading the language pack it needs.
Updating Visual Studio Code
Visual Studio Code is configured to receive automatic updates in the background and, usually, Microsoft releases updates monthly.
Note
Because VS Code receives monthly updates, some features might have been updated at the time of your reading, and others might be totally new. This is a necessary clarification you should keep in mind while reading, and it is also the reason why I will also provide links to the official documentation, so that you can stay up to date more easily.

Disabling automatic updates

VS Code release notes
Release notes contain the list of new and updated features, as well as hyperlinks that will open the proper feature page in the documentation.
Previewing Features with Insiders Builds
By default, the download page of the Visual Studio Code’s web site allows you to download the latest stable build. However, Microsoft periodically also releases preview builds of Visual Studio Code called Insiders builds that you can download to have a look at new and updated upcoming features before they are released to the general public.

Visual Studio Code Insiders builds
Insiders builds and stable builds can work side by side without any issues. Because each lives in its own environment, your setting customizations and extensions you installed on the stable build will not be automatically available to the Insiders build and vice versa, so you will need to provide them again.
Insiders builds are a very good option to have a look at what is coming with Visual Studio Code, but because they are not stable, final builds, it is not recommended you use them in production or with code you will release to production.
Summary
Visual Studio Code is not a simple code editor but a fully featured development environment optimized for web, mobile, and Cloud development. In this chapter, you saw how to install Visual Studio Code on Windows, macOS, and Linux distributions, learning how to select the appropriate installers and fine-tune the setup process. You also saw how to configure localization and updates. Finally, you had a look at the Insiders build, which offer previews of upcoming, unreleased features.
Now that you have your environment ready for use, it is time to start discovering the amazing features offered by Visual Studio Code. The next chapter walks through the environment, then in Chapter 3, "Language Support and Code Editing Features," you will see all the amazing code editing features that make Visual Studio Code a rich, powerful cross-platform editor.























































































































