Table Of ContentVisual Studio
Code Distilled
Evolved Code Editing for Windows,
macOS, and Linux
—
Alessandro Del Sole
Visual Studio Code
Distilled
Evolved Code Editing for
Windows, macOS, and Linux
Alessandro Del Sole
Visual Studio Code Distilled: Evolved Code Editing for Windows,
macOS, and Linux
Alessandro Del Sole
Cremona, Italy
ISBN-13 (pbk): 978-1-4842-4223-0 ISBN-13 (electronic): 978-1-4842-4224-7
https://doi.org/10.1007/978-1-4842-4224-7
Library of Congress Control Number: 2018965198
Copyright © 2019 by Alessandro Del Sole
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or
part of the material is concerned, specifically the rights of translation, reprinting, reuse of
illustrations, recitation, broadcasting, reproduction on microfilms or in any other physical way,
and transmission or information storage and retrieval, electronic adaptation, computer software,
or by similar or dissimilar methodology now known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark
symbol with every occurrence of a trademarked name, logo, or image we use the names, logos,
and images only in an editorial fashion and to the benefit of the trademark owner, with no
intention of infringement of the trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if
they are not identified as such, is not to be taken as an expression of opinion as to whether or not
they are subject to proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of
publication, neither the authors nor the editors nor the publisher can accept any legal
responsibility for any errors or omissions that may be made. The publisher makes no warranty,
express or implied, with respect to the material contained herein.
Managing Director, Apress Media LLC: Welmoed Spahr
Acquisitions Editor: Joan Murray
Development Editor: Laura Berendson
Coordinating Editor: Jill Balzano
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York,
233 Spring Street, 6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505,
e-mail orders-ny@springer-sbm.com, or visit www.springeronline.com. Apress Media, LLC is a
California LLC and the sole member (owner) is Springer Science + Business Media Finance Inc
(SSBM Finance Inc). SSBM Finance Inc is a Delaware corporation.
For information on translations, please e-mail rights@apress.com, or visit http://www.apress.
com/rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use.
eBook versions and licenses are also available for most titles. For more information, reference
our Print and eBook Bulk Sales web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available
to readers on GitHub via the book's product page, located at www.apress.com/978-1-4842-4223-0.
For more detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
To Angelica, the love of my life.
Table of Contents
About the Author ���������������������������������������������������������������������������������xi
Acknowledgments �����������������������������������������������������������������������������xiii
Introduction ����������������������������������������������������������������������������������������xv
Chapter 1: Introducing Visual Studio Code �������������������������������������������1
Introducing Visual Studio Code �����������������������������������������������������������������������������2
When and Why Visual Studio Code ������������������������������������������������������������������������3
Installing and Configuring Visual Studio Code ������������������������������������������������������5
Installing Visual Studio Code on Windows �������������������������������������������������������6
Installing Visual Studio Code on macOS ����������������������������������������������������������9
Installing Visual Studio Code on Linux �����������������������������������������������������������10
Localization Support ��������������������������������������������������������������������������������������12
Updating Visual Studio Code ��������������������������������������������������������������������������13
Previewing Features with Insiders Builds �����������������������������������������������������15
Summary�������������������������������������������������������������������������������������������������������������17
Chapter 2: Getting to Know the Environment �������������������������������������19
The Welcome Page ����������������������������������������������������������������������������������������������20
The Code Editor ���������������������������������������������������������������������������������������������������21
Reordering, Resizing, and Zooming Editor Windows �������������������������������������22
The Status Bar ����������������������������������������������������������������������������������������������������23
The Activity Bar ���������������������������������������������������������������������������������������������������24
v
TTaabbllee ooff CCoonnTTeennTTss
The Side Bar ��������������������������������������������������������������������������������������������������������26
The Explorer Bar ��������������������������������������������������������������������������������������������26
The Search Tool ���������������������������������������������������������������������������������������������31
The Git Bar �����������������������������������������������������������������������������������������������������32
The Debug Bar �����������������������������������������������������������������������������������������������34
The Extensions Bar ����������������������������������������������������������������������������������������35
The Settings Button ���������������������������������������������������������������������������������������36
Navigating Between Files �����������������������������������������������������������������������������������36
The Command Palette �����������������������������������������������������������������������������������������37
The Panels Area ��������������������������������������������������������������������������������������������������38
The Problems Panel ���������������������������������������������������������������������������������������38
The Output Panel �������������������������������������������������������������������������������������������40
The Debug Console Panel ������������������������������������������������������������������������������41
Working with the Terminal �����������������������������������������������������������������������������42
Summary�������������������������������������������������������������������������������������������������������������43
Chapter 3: Language Support and Code Editing Features ������������������45
Language Support �����������������������������������������������������������������������������������������������46
Working with C# and C++ �����������������������������������������������������������������������������47
Basic Code Editing Features �������������������������������������������������������������������������������48
Working with Text ������������������������������������������������������������������������������������������48
Syntax Colorization ����������������������������������������������������������������������������������������49
Delimiter Matching and Text Selection ����������������������������������������������������������51
Code Block Folding ����������������������������������������������������������������������������������������51
Multicursors ��������������������������������������������������������������������������������������������������52
Reusable Code Snippets ��������������������������������������������������������������������������������52
Word Completion �������������������������������������������������������������������������������������������54
Minimap Mode �����������������������������������������������������������������������������������������������55
vi
TTaabbllee ooff CCoonnTTeennTTss
Whitespace Rendering and Breadcrumbs �����������������������������������������������������56
Markdown Preview ����������������������������������������������������������������������������������������58
Evolved Code Editing �������������������������������������������������������������������������������������������59
Working with IntelliSense ������������������������������������������������������������������������������60
Parameter Hints ���������������������������������������������������������������������������������������������62
Inline Documentation with Tooltips ���������������������������������������������������������������62
Go To Definition ����������������������������������������������������������������������������������������������63
Find All References ����������������������������������������������������������������������������������������65
Peek Definition ����������������������������������������������������������������������������������������������66
Renaming Symbols and Identifiers ����������������������������������������������������������������67
Live Code Analysis �����������������������������������������������������������������������������������������68
Summary�������������������������������������������������������������������������������������������������������������76
Chapter 4: Working with Files and Folders�����������������������������������������77
Visual Studio Code and Project Systems ������������������������������������������������������������77
Working with Individual Files ������������������������������������������������������������������������������78
Creating Files �������������������������������������������������������������������������������������������������79
File Encoding, Line Terminators, and Line Browsing �������������������������������������80
Working with Folders and Projects ���������������������������������������������������������������������82
Opening a Folder �������������������������������������������������������������������������������������������84
Opening �NET Core Solutions �������������������������������������������������������������������������86
Opening JavaScript and TypeScript Projects �������������������������������������������������87
Opening Loose Folders ����������������������������������������������������������������������������������88
Working with Workspaces �����������������������������������������������������������������������������������89
Creating Workspaces �������������������������������������������������������������������������������������91
Opening Existing Workspaces �����������������������������������������������������������������������92
Workspace Structure �������������������������������������������������������������������������������������92
Summary�������������������������������������������������������������������������������������������������������������93
vii
TTaabbllee ooff CCoonnTTeennTTss
Chapter 5: Customizing Visual Studio Code ���������������������������������������95
Customizations and Extensions Explained ����������������������������������������������������������95
Customizing Visual Studio Code ��������������������������������������������������������������������������97
Theme Selection ��������������������������������������������������������������������������������������������97
Customizing the Environment ������������������������������������������������������������������������99
Customizing Key Bindings ���������������������������������������������������������������������������106
Summary�����������������������������������������������������������������������������������������������������������110
Chapter 6: Installing and Managing Extensions �������������������������������111
Installing Extensions �����������������������������������������������������������������������������������������111
Extension Recommendations ����������������������������������������������������������������������115
Useful Extensions ����������������������������������������������������������������������������������������117
Managing Extensions ����������������������������������������������������������������������������������������118
Configuring Extensions ��������������������������������������������������������������������������������120
Hints About Extension Authoring �����������������������������������������������������������������������122
Summary�����������������������������������������������������������������������������������������������������������122
Chapter 7: Source Control with Git ���������������������������������������������������125
Source Control in Visual Studio Code ����������������������������������������������������������������125
Downloading Other Source Control Providers ���������������������������������������������126
Managing Repositories �������������������������������������������������������������������������������������127
Initializing a Local Git Repository ����������������������������������������������������������������128
Creating a Remote Repository ���������������������������������������������������������������������130
Handling File Changes ��������������������������������������������������������������������������������������132
Staging Changes �����������������������������������������������������������������������������������������134
Managing Commits �������������������������������������������������������������������������������������������135
Working with the Git Command Line Interface �������������������������������������������������137
viii
TTaabbllee ooff CCoonnTTeennTTss
Creating and Managing Branches ���������������������������������������������������������������������138
Switching to a Different Branch ������������������������������������������������������������������140
Merging from a Branch ��������������������������������������������������������������������������������140
Deleting Branches ���������������������������������������������������������������������������������������141
Adding Power to the Git Tooling with Extensions ����������������������������������������������142
Git History ����������������������������������������������������������������������������������������������������142
GitLens ���������������������������������������������������������������������������������������������������������144
GitHub Pull Requests �����������������������������������������������������������������������������������148
Working with Azure DevOps and Team Foundation Server �������������������������������150
Summary�����������������������������������������������������������������������������������������������������������154
Chapter 8: Automating Tasks �����������������������������������������������������������157
Understanding Tasks �����������������������������������������������������������������������������������������158
Tasks Types �������������������������������������������������������������������������������������������������159
Running and Managing Tasks ����������������������������������������������������������������������159
The Default Build Task ���������������������������������������������������������������������������������164
Auto-Detected Tasks ������������������������������������������������������������������������������������164
Configuring Tasks ����������������������������������������������������������������������������������������166
Running Files with a Default Program ���������������������������������������������������������188
Summary�����������������������������������������������������������������������������������������������������������189
Chapter 9: Running and Debugging Code �����������������������������������������191
Creating Applications ����������������������������������������������������������������������������������������191
Creating �NET Core Projects ������������������������������������������������������������������������192
Creating Projects on Other Platforms ����������������������������������������������������������195
Debugging Your Code ����������������������������������������������������������������������������������������196
Configuring the Debugger ���������������������������������������������������������������������������198
ix
TTaabbllee ooff CCoonnTTeennTTss
Managing Breakpoints���������������������������������������������������������������������������������202
Debugging an Application ����������������������������������������������������������������������������203
Supporting Azure, Docker, and Artificial Intelligence �����������������������������������������207
Summary�����������������������������������������������������������������������������������������������������������209
Index �������������������������������������������������������������������������������������������������211
x