Full download Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition Alessandro Del Sole pdf docx
Full download Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition Alessandro Del Sole pdf docx
com
https://ebookmass.com/product/visual-studio-code-distilled-
evolved-code-editing-for-windows-macos-and-linux-third-
edition-alessandro-del-sole/
OR CLICK HERE
DOWLOAD NOW
https://ebookmass.com/product/international-fire-code-international-
code-council-series-2021-1st-edition-international-code-council/
ebookmass.com
https://ebookmass.com/product/expertddx-musculoskeletal-2nd-edition-
kirkland-w-davis-2/
ebookmass.com
Tratado de Diálisis Peritoneal 3Ed Montenegro 3Ed Edition
Jesus Montenegro
https://ebookmass.com/product/tratado-de-dialisis-peritoneal-3ed-
montenegro-3ed-edition-jesus-montenegro/
ebookmass.com
https://ebookmass.com/product/ebook-pdf-introduction-to-global-
politics-5th-edition/
ebookmass.com
https://ebookmass.com/product/schalms-veterinary-hematology-7th-
edition-marjory-b-brooks/
ebookmass.com
https://ebookmass.com/product/memory-a-self-referential-account-jordi-
fernandez/
ebookmass.com
https://ebookmass.com/product/fluid-inclusion-effect-in-flotation-of-
sulfide-minerals-1st-edition-shuming-wen/
ebookmass.com
Sustainable Investing: What Everyone Needs to Know H. Kent
Baker
https://ebookmass.com/product/sustainable-investing-what-everyone-
needs-to-know-h-kent-baker-2/
ebookmass.com
Visual Studio
Code Distilled
Evolved Code Editing for Windows,
macOS, and Linux
—
Third Edition
—
Alessandro Del Sole
Visual Studio Code
Distilled
Evolved Code Editing for Windows,
macOS, and Linux
Third Edition
Acknowledgments���������������������������������������������������������������������������������������������������xv
Introduction�����������������������������������������������������������������������������������������������������������xvii
v
Table of Contents
vi
Table of Contents
vii
Table of Contents
viii
Table of Contents
ix
Table of Contents
Index��������������������������������������������������������������������������������������������������������������������� 331
xi
About the Author
Alessandro Del Sole is a senior software engineer for a
healthcare company, building mobile apps for doctors and
dialysis patients. He has been in the software industry for
more than 20 years, focusing on Microsoft technologies
such as .NET, C#, Visual Studio, and Xamarin. He has been
a trainer, consultant, and a Microsoft MVP since 2008 and
is the author of many technical books. He is a Xamarin
Certified Mobile Developer, Microsoft Certified Professional,
and a Microsoft Programming Specialist in C#.
xiii
Acknowledgments
Thanks to Smriti Srivastava, Nirmal Selvaraj, Laura Berendson, and everyone else at
Apress for the opportunity, renewed trust, and the great teamwork on this book.
Special thanks to the technical editor Damien Foggon, who contributed to the
quality and accuracy of the content.
Special thanks to my wife Angelica, for her continuous and strong support.
xv
Introduction
One of the most common requirements in software development today is building
applications and services that run on multiple systems and devices, especially with the
continued expansion of cloud and artificial intelligence services, and of architectures
based on microservices.
Developers have many options for building cross-platform and cross-device
software, from languages to development platforms and tools. However, in most cases,
such tools rely on proprietary systems, which result in strong dependencies. Moreover,
most development tools target specific platforms and development scenarios. Microsoft
Visual Studio Code takes a step forward by providing a fully featured development
environment for Windows, macOS, and Linux that offers not only advanced coding
features but also integrated tools. These tools span across the entire application lifecycle,
from coding to debugging to team collaboration. The full tooling is consistent across
these languages and frameworks, natively or via extensions, so that developers share the
same experience regardless of the technology they use.
With .NET 7 and with .NET MAUI recently released, and with artificial intelligence
services becoming part of the modern software implementation, Visual Studio Code
becomes even more important to support cross-platform development on multiple
operating systems. In this book, developers with any skill level learn how to leverage
Visual Studio Code to target scenarios such as web, cloud, and mobile development
using the programming language of their choice. This book provides guidance on
building apps for any system and any device. This includes managing the application
lifecycle, as well as team collaboration.
xvii
CHAPTER 1
Note In this book, I refer to the product using its full name, Visual Studio Code, as
well as its friendly names, VS Code and Code, interchangeably.
1
© Alessandro Del Sole 2023
A. Del Sole, Visual Studio Code Distilled, https://doi.org/10.1007/978-1-4842-9484-0_1
Chapter 1 Introducing Visual Studio Code
as Node.js and .NET. It also has 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. It 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. Visual Studio Code is therefore a complete development tool, rather than
being a simple code editor. For a richer development experience, consider Microsoft
Visual Studio 2022 on Windows and Visual Studio 2022 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; you discover how you can use it as a powerful code editor and as a complete
environment for end-to-end development. Except where necessary to differentiate
operating systems, figures are based on Microsoft Windows 10, but typically there is
no difference in the interface on Windows 11, Linux, and macOS. Also, Visual Studio
Code includes several color themes that style its layout. In this book, figures display the
Light (Visual Studio) theme, so you might see different colors on your own screen if you
choose a different color theme. Chapter 5 explains how to change the theme, but if you
want to be consistent with the book’s figures, simply choose File ➤ Preferences ➤ Color
Theme and select the Visual Studio 2019 Light Theme. It is worth mentioning that the
theme you select does not affect the features described in this book.
2
Chapter 1 Introducing Visual Studio Code
create portable web applications. Forcing you to build cross-platform, portable web apps
with Microsoft Visual Studio 2022 would make you dependent on that specific integrated
development environment (IDE). This also applies to the (free) Visual Studio 2022
Community edition. Conversely, though Visual Studio Code certainly is not intended to
be a replacement for more powerful and complete environments, it can run on a variety
of operating systems and can manage different project types, as well as the most popular
languages. To accomplish this, Visual Studio Code provides the following core features:
In order to properly combine all these features into one tool, Visual Studio Code
provides a coding environment based on folders, which makes it easy to work with code
files that are not organized within projects and offers a unified way to work with different
languages. Starting with this assumption, Visual Studio Code offers an advanced editing
experience with features that are common to many supported languages, plus some
features that are available to specific languages. As you’ll learn throughout the book,
Code also makes it easy to extend its built-in features by supplying custom languages,
syntax coloring, editing tools, debuggers, and much more via a number of extensibility
points. It is a code-centric tool, with primary focus on web, cross-platform code. That
said, it does not provide all of the features you need for full, more complex application
development and application lifecycle management and it is not intended to be the best
choice with some development platforms. If you have to make a choice, consider the
following points:
• Visual Studio Code can produce binaries and executable files only if
the language you use has support to do so through a command-line
interface (CLI), a compiler, and a debugger. If you use a language
for which there is no extensive support (e.g., the open-source Go
programming language, https://golang.org), Visual Studio Code
3
Chapter 1 Introducing Visual Studio Code
If your requirements are different, consider Microsoft Visual Studio 2022 or Microsoft
Visual Studio 2022 for Mac instead, which are optimized for building, testing, deploying,
and maintaining multiple types of applications.
Now that you have a clearer idea of Code’s goals, you are ready to learn the amazing
editing features that elevate it above any other code editor.
4
Chapter 1 Introducing Visual Studio Code
Note Visual Studio Code can also run in Portable Mode, which means that
you can create a self-containing folder that can be moved across environments.
Since this is a very specific scenario, it isn’t covered in this book; you can read
the documentation (https://code.visualstudio.com/docs/editor/
portable) to learn the steps required to generate Portable Mode.
In the following sections, you learn some tips for installing Visual Studio Code on
various supported systems.
Note The latest stable release of Visual Studio Code at the time of this writing is
version 1.76.0, released in February 2023.
5
Chapter 1 Introducing Visual Studio Code
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
6
Chapter 1 Introducing Visual Studio Code
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.
A specific dialog box will inform you once the installation process has completed.
The installation folder for the user-level installer is C:\Users\username\AppData\Local\
Programs\Microsoft VS Code, while the installation folder for the global installer is
C:\Program Files\Microsoft VS Code on 64-bit systems and C:\Program Files(x86)\
Microsoft VS Code on 32-bit systems. You will find a shortcut to Visual Studio Code in
the Start menu and on the Desktop, if you selected the option to create a shortcut during
the installation. When it starts, Visual Studio Code appears as shown in Figure 1-2.
7
Chapter 1 Introducing Visual Studio Code
8
Chapter 1 Introducing Visual Studio Code
9
10
Chapter 1
Introducing Visual Studio Code
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 could install the latest Ubuntu version (https://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 it's started, VS Code checks for the operating system
language and, if it's different from English, it shows a popup message suggesting to
install a language pack for the culture of your operating system. The localization support
can be also enabled manually.
To accomplish this, choose View ➤ Command Palette. When the text box appears at
the top of the page, type the following command:
You can also just type configure display and the command will be automatically
listed in the command palette (see Figure 1-5).
11
Chapter 1 Introducing Visual Studio Code
When you click this command, the Command Palette displays the following options:
When you select a language pack, VS Code will download the appropriate package
and will show a message saying that a restart is required in order to localize the user
interface.
Note Because VS Code receives monthly updates, some features might have
been updated at the time of your reading, and others might be new. This is a
necessary clarification you should keep in mind while reading, and it is also the
reason that I also provide links to the official documentation, so that you can stay
up to date more easily.
Additionally, you can manually check for updates by choosing Help ➤ Check for
Updates on Windows and Linux or choosing Code ➤ Check for Updates on macOS. If
you do not want to receive automatic updates and prefer manual updates, you can
disable automatic updates by choosing File ➤ Preferences ➤ Settings. Then, in the
Update section of the Application settings group, disable the Background Updates
option. Figure 1-6 shows an example based on Windows. (Obviously, on macOS and
Linux, the Enable Windows Background Updates option is not available.)
12
Chapter 1 Introducing Visual Studio Code
You follow the same steps to re-enable updates in the background. Whenever Visual
Studio Code receives an update, you will receive a notification suggesting that you restart
Code in order to apply the changes. The first time you restart Visual Studio Code after an
update, you will see the release notes for the version that was installed, as demonstrated
in Figure 1-7.
13
Chapter 1 Introducing Visual Studio Code
Release notes contain the list of new and updated features, as well as hyperlinks that
will open the proper feature page in the documentation. You can recall release notes at
any time by choosing Help ➤ Show Release Notes.
14
Chapter 1 Introducing Visual Studio Code
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 way to see 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.
15
Chapter 1 Introducing Visual Studio Code
When running in the browser, Visual Studio Code offers the same features available
on the regular desktop app. You can also fully customize your development environment
and experience, and changes will be saved into the local cache. This is a very interesting
alternative, but still in preview stage at the time of this writing.
16
Chapter 1 Introducing Visual Studio Code
S
ummary
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. Next, you looked at the Insiders
builds, which offer previews of upcoming, unreleased features. Finally, you saw Visual
Studio Code running in the browser as a web app, with the same features as the desktop
version.
Now that your environment is 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, you learn about all the amazing code-editing features
that make Visual Studio Code a rich, powerful crossplatform editor.
17
CHAPTER 2
Getting to Know
the Environment
Before you use Visual Studio Code as the editor of your choice, you need to know how
the workspace is organized and what commands and tools are available, in order to get
the most out of the development environment.
The VS Code user interface and layout are optimized to maximize the space for code
editing, and it also provides easy shortcuts to quickly access all the additional tools you
need in a given context. More specifically, the user interface is divided into five areas:
the code editor, the Status Bar, the Activity Bar, the Panels area, and the Side Bar. This
chapter explains how the user interface is organized and how you can be productive
using it.
Note All the features discussed in this chapter apply to any file in any language,
and they are available regardless of the language you see in the figures (normally
C#). You can open one or more code files via File ➤ Open File to access the editor
windows and explore the features discussed in this chapter. Then, Chapter 4
discusses more thoroughly how to work with individual files and multiple files, in
one or more languages, concurrently.
19
© Alessandro Del Sole 2023
A. Del Sole, Visual Studio Code Distilled, https://doi.org/10.1007/978-1-4842-9484-0_2
Chapter 2 Getting to Know the Environment
On the left side of the page, under the Start group, you find shortcuts for creating and
opening files and folders, and for cloning an existing Git repository. Under the Recent
group is a list of recently opened files and folders that you can click for fast opening.
Under the Walkthroughs group, there are useful links to product documentation,
tutorials, cheat sheets, introductory videos, and other learning resources about Visual
Studio Code.
By default, the Welcome page is set to appear every time you launch VS Code. To
change this default behavior, remove the check mark from the Show Welcome Page On
Startup check box. To re-enable the Welcome page on startup, choose Help ➤ Welcome
and add the check mark back.
20
Chapter 2 Getting to Know the Environment
• Press Ctrl+\ (or ⌘+\ on macOS) to split the editor into two.
21
Chapter 2 Getting to Know the Environment
Open editors can also be organized into groups. To accomplish this, you can drag
and drop the title of an open editor close to another one and they will be grouped in
the same space and the Explorer Bar will show the list of groups. You can quickly switch
between editors by pressing Ctrl+1, 2, and so on, until 9. Keep in mind this works with up
to nine editor windows. The code editor is the heart of Visual Studio Code and provides
tons of powerful productivity features that are discussed in detail in the next chapter. For
now, it is enough to know how to open and arrange editor windows.
22
Chapter 2 Getting to Know the Environment
The Status Bar contains the following information, from left to right:
• Tab size, in this case Spaces: 4. You can click this to change the
indentation size and to convert indentation to tabs or spaces.
It is worth mentioning that the color of the Status Bar changes depending on the
situation. For example, it is purple when you open a single file, blue when you open a
folder, and orange when Visual Studio Code is in debugging mode. Additionally, third-
party extensions might use the Status Bar to display their own information.
23
Chapter 2 Getting to Know the Environment
The Activity Bar provides shortcuts for the Explorer, Search, Git, Run and Debug,
Extensions, Accounts, and Settings tools, each described in the next section. When you
click a shortcut, the Side Bar related to the selected tool becomes visible. You can click
the same shortcut again to collapse the Side Bar.
24
Chapter 2 Getting to Know the Environment
clicking the ... button and then selecting Open Editors. It also includes open files that are
not part of a project, folder, or files that have been modified. These are instead shown in
a subview whose name is the folder or project name. Figure 2-5 provides an example of
Explorer.
25
Chapter 2 Getting to Know the Environment
You must hover your cursor over any file or folder to make the four buttons visible.
The subview that shows a folder structure provides four buttons (from left to right): New
File, New Folder, Refresh Explorer, and Collapse Folders in Explorer, each of which is
self-explanatory. The OPEN EDITORS subview has three buttons (which you get when
hovering over with the mouse): New Untitled Text File, Save All, and Close All Editors.
Right-clicking a folder or filename in Explorer provides a context menu that offers
common commands (such as Open to the Side, referenced earlier in this chapter). A very
interesting command is Reveal in File Explorer (or Reveal to Finder on Mac and Open
Containing Folder on Linux), which opens the containing folder for the selected item.
Notice that the Explorer icon in the Activity Bar also reports the number of unsaved files.
26
Chapter 2 Getting to Know the Environment
27
Random documents with unrelated
content Scribd suggests to you:
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or expense
to the user, provide a copy, a means of exporting a copy, or a means
of obtaining a copy upon request, of the work in its original “Plain
Vanilla ASCII” or other form. Any alternate format must include the
full Project Gutenberg™ License as specified in paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive from
the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth in
paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.
Our website is not just a platform for buying books, but a bridge
connecting readers to the timeless values of culture and wisdom. With
an elegant, user-friendly interface and an intelligent search system,
we are committed to providing a quick and convenient shopping
experience. Additionally, our special promotions and home delivery
services ensure that you save time and fully enjoy the joy of reading.
ebookmass.com