100% found this document useful (1 vote)
11 views

Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition Alessandro Del Sole instant download

The document provides information about various ebooks available for download, including 'Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition' by Alessandro Del Sole. It includes links to download the full versions of these ebooks and highlights other titles in the International Code Council Series. Additionally, it contains details about the content and structure of the Visual Studio Code book, including chapters on installation, customization, and language support.

Uploaded by

nanaeboinas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
11 views

Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition Alessandro Del Sole instant download

The document provides information about various ebooks available for download, including 'Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux - Third Edition' by Alessandro Del Sole. It includes links to download the full versions of these ebooks and highlights other titles in the International Code Council Series. Additionally, it contains details about the content and structure of the Visual Studio Code book, including chapters on installation, customization, and language support.

Uploaded by

nanaeboinas
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 73

Visit https://ebookmass.

com to download the full version and


browse more ebooks or textbooks

Visual Studio Code Distilled: Evolved Code Editing


for Windows, macOS, and Linux - Third Edition
Alessandro Del Sole

_____ Press the link below to begin your download _____

https://ebookmass.com/product/visual-studio-code-distilled-
evolved-code-editing-for-windows-macos-and-linux-third-
edition-alessandro-del-sole/

Access ebookmass.com now to download high-quality


ebooks or textbooks
We believe these products will be a great fit for you. Click
the link to download now, or visit ebookmass.com
to discover even more!

Visual Studio Code Distilled: Evolved Code Editing for


Windows, macOS, and Linux 3 / converted Edition Alessandro
Del Sole
https://ebookmass.com/product/visual-studio-code-distilled-evolved-
code-editing-for-windows-macos-and-linux-3-converted-edition-
alessandro-del-sole/

International Residential Code for One- and Two-Family


Dwellings (International Code Council Series) 2018 1st
Edition International Code Council
https://ebookmass.com/product/international-residential-code-for-one-
and-two-family-dwellings-international-code-council-series-2018-1st-
edition-international-code-council/

International Fire Code (International Code Council


Series) 2021 1st Edition International Code Council

https://ebookmass.com/product/international-fire-code-international-
code-council-series-2021-1st-edition-international-code-council/

International Zoning Code (international Code Council


Series) 2018 International Code Council

https://ebookmass.com/product/international-zoning-code-international-
code-council-series-2018-international-code-council/
IBC International Building Code (International Code
Council Series) 2018 1st Edition International Code
Council
https://ebookmass.com/product/ibc-international-building-code-
international-code-council-series-2018-1st-edition-international-code-
council/

International Energy Conservation Code (International Code


Council Series) 2018 1st Edition International Code
Council
https://ebookmass.com/product/international-energy-conservation-code-
international-code-council-series-2018-1st-edition-international-code-
council/

Let's Code It! 2022-2023 Code Edition Shelley Safian

https://ebookmass.com/product/lets-code-it-2022-2023-code-edition-
shelley-safian/

IPMC International Property Maintenance Code


(International Code Council Series) 2018 1st Edition
International Code Council
https://ebookmass.com/product/ipmc-international-property-maintenance-
code-international-code-council-series-2018-1st-edition-international-
code-council/

International Swimming Pool and Spa Code 2021 1st Edition


International Code Council

https://ebookmass.com/product/international-swimming-pool-and-spa-
code-2021-1st-edition-international-code-council/
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

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-9483-3 ISBN-13 (electronic): 978-1-4842-9484-0


https://doi.org/10.1007/978-1-4842-9484-0

Copyright © 2023 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: Smriti Srivastava
Development Editor: Laura Berendson
Coordinating Editor: Mark Powers
Copy Editor: Kezia Endsley
Cover designed by eStudioCalamar
Cover image designed by Freepik (www.freepik.com)
Distributed to the book trade worldwide by Springer Science+Business Media New York, 1 New York Plaza,
Suite 4600, New York, NY 10004-1562, USA. 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 booktranslations@springernature.com; for reprint,
paperback, or audio rights, please e-mail bookpermissions@springernature.com.
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 (github.com/apress). For more detailed information, please visit http://www.apress.
com/source-code.
Printed on acid-free paper
To my wonderful wife, Angelica. You are my reason to live.
Table of Contents
About the Author��������������������������������������������������������������������������������������������������� xiii

Acknowledgments���������������������������������������������������������������������������������������������������xv
Introduction�����������������������������������������������������������������������������������������������������������xvii

Chapter 1: Introducing Visual Studio Code��������������������������������������������������������������� 1


Visual Studio Code, a Cross-Platform Development Tool�������������������������������������������������������������� 1
When and Why Visual Studio Code������������������������������������������������������������������������������������������������ 2
Installing and Configuring Visual Studio Code������������������������������������������������������������������������������ 4
Installing Visual Studio Code on Windows������������������������������������������������������������������������������� 6
Installing Visual Studio Code on macOS���������������������������������������������������������������������������������� 8
Installing Visual Studio Code on Linux������������������������������������������������������������������������������������� 9
Localization Support�������������������������������������������������������������������������������������������������������������� 11
Updating Visual Studio Code�������������������������������������������������������������������������������������������������� 12
Previewing Features with Insiders Builds����������������������������������������������������������������������������� 14
Visual Studio Code on Web���������������������������������������������������������������������������������������������������� 16
Summary������������������������������������������������������������������������������������������������������������������������������������ 17

Chapter 2: Getting to Know the Environment��������������������������������������������������������� 19


The Welcome Page���������������������������������������������������������������������������������������������������������������������� 19
The Code Editor��������������������������������������������������������������������������������������������������������������������������� 21
Reordering, Resizing, and Zooming Editor Windows������������������������������������������������������������� 22
The Status Bar���������������������������������������������������������������������������������������������������������������������������� 22
The Activity Bar��������������������������������������������������������������������������������������������������������������������������� 23
The Side Bar�������������������������������������������������������������������������������������������������������������������������������� 24
The Explorer Bar�������������������������������������������������������������������������������������������������������������������� 24
The Search Tool��������������������������������������������������������������������������������������������������������������������� 30

v
Table of Contents

The Git Bar����������������������������������������������������������������������������������������������������������������������������� 31


The Run and Debug Bar��������������������������������������������������������������������������������������������������������� 32
The Extensions Bar���������������������������������������������������������������������������������������������������������������� 33
The Accounts Button������������������������������������������������������������������������������������������������������������� 34
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������������������������������������������������������������������������������������������������������ 40
Working with the Terminal����������������������������������������������������������������������������������������������������� 41
Summary������������������������������������������������������������������������������������������������������������������������������������ 43

Chapter 3: Language Support and Code Editing Features�������������������������������������� 45


Language Support����������������������������������������������������������������������������������������������������������������������� 45
Working with C# and C++����������������������������������������������������������������������������������������������������� 46
Working with Python������������������������������������������������������������������������������������������������������������� 47
Working with Julia����������������������������������������������������������������������������������������������������������������� 48
Working with Go�������������������������������������������������������������������������������������������������������������������� 48
Basic Code Editing Features������������������������������������������������������������������������������������������������������� 48
Working with Text������������������������������������������������������������������������������������������������������������������ 49
Syntax Colorization���������������������������������������������������������������������������������������������������������������� 50
Delimiter Matching and Text Selection���������������������������������������������������������������������������������� 51
Code Block Folding���������������������������������������������������������������������������������������������������������������� 52
Multicursors�������������������������������������������������������������������������������������������������������������������������� 52
Reusable Code Snippets�������������������������������������������������������������������������������������������������������� 53
Word Completion������������������������������������������������������������������������������������������������������������������� 54
Minimap Mode����������������������������������������������������������������������������������������������������������������������� 55
Sticky Scroll��������������������������������������������������������������������������������������������������������������������������� 56
Whitespace Rendering and Breadcrumbs����������������������������������������������������������������������������� 57
Markdown Preview���������������������������������������������������������������������������������������������������������������� 58

vi
Table of Contents

Evolved Code Editing������������������������������������������������������������������������������������������������������������������� 59


Working with IntelliSense������������������������������������������������������������������������������������������������������ 60
Parameter Hints��������������������������������������������������������������������������������������������������������������������� 62
Inline Documentation with Tooltips��������������������������������������������������������������������������������������� 63
Go to Definition and Peek Definition�������������������������������������������������������������������������������������� 64
Go to Implementation and Peek Implementations����������������������������������������������������������������� 66
Finding References���������������������������������������������������������������������������������������������������������������� 67
Renaming Symbols and Identifiers���������������������������������������������������������������������������������������� 70
Live Code Analysis����������������������������������������������������������������������������������������������������������������� 72
Hints About IntelliCode���������������������������������������������������������������������������������������������������������� 80
Summary������������������������������������������������������������������������������������������������������������������������������������ 80

Chapter 4: Working with Files and Folders������������������������������������������������������������ 81


Visual Studio Code and Project Systems������������������������������������������������������������������������������������ 81
Working with Individual Files������������������������������������������������������������������������������������������������������ 82
Creating Files������������������������������������������������������������������������������������������������������������������������� 84
File Encoding, Line Terminators, and Line Browsing������������������������������������������������������������� 86
Working with Folders and Projects��������������������������������������������������������������������������������������������� 87
Opening a Folder������������������������������������������������������������������������������������������������������������������� 88
Opening .NET Solutions��������������������������������������������������������������������������������������������������������� 90
Opening JavaScript and TypeScript Projects������������������������������������������������������������������������� 91
Opening Loose Folders���������������������������������������������������������������������������������������������������������� 92
Working with Workspaces����������������������������������������������������������������������������������������������������������� 92
Creating Workspaces������������������������������������������������������������������������������������������������������������� 95
Opening Existing Workspaces����������������������������������������������������������������������������������������������� 95
Workspace Structure������������������������������������������������������������������������������������������������������������� 96
Security: Workspace Trust����������������������������������������������������������������������������������������������������� 97
Summary���������������������������������������������������������������������������������������������������������������������������������� 101

vii
Table of Contents

Chapter 5: Customizing Visual Studio Code��������������������������������������������������������� 103


Customizations and Extensions Explained�������������������������������������������������������������������������������� 103
Customizing Visual Studio Code������������������������������������������������������������������������������������������������ 105
Theme Selection������������������������������������������������������������������������������������������������������������������ 105
Customizing the Environment���������������������������������������������������������������������������������������������� 107
Customizing Keyboard Shortcuts���������������������������������������������������������������������������������������� 118
Creating Reusable Profiles�������������������������������������������������������������������������������������������������������� 123
Summary���������������������������������������������������������������������������������������������������������������������������������� 125

Chapter 6: Installing and Managing Extensions��������������������������������������������������� 127


Installing Extensions����������������������������������������������������������������������������������������������������������������� 127
Extension Recommendations���������������������������������������������������������������������������������������������� 131
Useful Extensions���������������������������������������������������������������������������������������������������������������� 133
Managing Extensions���������������������������������������������������������������������������������������������������������������� 134
Configuring Extensions�������������������������������������������������������������������������������������������������������� 136
Writing Your First Extension������������������������������������������������������������������������������������������������������ 138
Setting Up the Environment������������������������������������������������������������������������������������������������� 139
Creating an Extension���������������������������������������������������������������������������������������������������������� 140
Developing the Extension���������������������������������������������������������������������������������������������������� 142
Running the Extension��������������������������������������������������������������������������������������������������������� 145
Packaging Extensions��������������������������������������������������������������������������������������������������������� 147
Extension Development Summary�������������������������������������������������������������������������������������� 148
Summary���������������������������������������������������������������������������������������������������������������������������������� 149

Chapter 7: Source Control with Git����������������������������������������������������������������������� 151


Source Control in Visual Studio Code���������������������������������������������������������������������������������������� 151
Downloading Other Source Control Providers��������������������������������������������������������������������� 152
Managing Repositories������������������������������������������������������������������������������������������������������������� 153
Initializing a Local Git Repository���������������������������������������������������������������������������������������� 154
Creating a Remote Repository��������������������������������������������������������������������������������������������� 155
Handling File Changes�������������������������������������������������������������������������������������������������������������� 159
Staging Changes����������������������������������������������������������������������������������������������������������������� 160

viii
Table of Contents

Managing Commits������������������������������������������������������������������������������������������������������������������� 161


Working with the Git Command-Line Interface������������������������������������������������������������������������� 163
Creating and Managing Branches��������������������������������������������������������������������������������������������� 164
Switching to a Different Branch������������������������������������������������������������������������������������������ 166
Merging from a Branch�������������������������������������������������������������������������������������������������������� 166
Hints About Rebasing Branches������������������������������������������������������������������������������������������ 170
Deleting Branches��������������������������������������������������������������������������������������������������������������� 170
Adding Power to the Git Tooling with Extensions���������������������������������������������������������������������� 170
Git History���������������������������������������������������������������������������������������������������������������������������� 171
GitLens��������������������������������������������������������������������������������������������������������������������������������� 172
GitHub Pull Requests and Issues����������������������������������������������������������������������������������������� 174
Working with Azure DevOps������������������������������������������������������������������������������������������������������ 178
Creating a Team Project������������������������������������������������������������������������������������������������������ 178
Connecting Visual Studio Code to a Remote Repository����������������������������������������������������� 181
Summary���������������������������������������������������������������������������������������������������������������������������������� 182

Chapter 8: Automating Tasks������������������������������������������������������������������������������� 185


Understanding Tasks����������������������������������������������������������������������������������������������������������������� 185
Tasks Types������������������������������������������������������������������������������������������������������������������������� 186
Running and Managing Tasks���������������������������������������������������������������������������������������������� 187
The Default Build Task��������������������������������������������������������������������������������������������������������� 192
Auto-Detected Tasks������������������������������������������������������������������������������������������������������������ 192
Configuring Tasks���������������������������������������������������������������������������������������������������������������� 194
Running Files with a Default Program��������������������������������������������������������������������������������� 213
Summary���������������������������������������������������������������������������������������������������������������������������������� 213

Chapter 9: Building and Debugging Applications������������������������������������������������� 215


Creating Applications���������������������������������������������������������������������������������������������������������������� 215
The Status of Microsoft .NET����������������������������������������������������������������������������������������������� 216
Creating .NET Projects��������������������������������������������������������������������������������������������������������� 217
Creating Projects on Other Platforms���������������������������������������������������������������������������������� 223

ix
Table of Contents

Debugging Your Code���������������������������������������������������������������������������������������������������������������� 225


Configuring the Debugger��������������������������������������������������������������������������������������������������� 227
Managing Breakpoints�������������������������������������������������������������������������������������������������������� 230
Debugging an Application���������������������������������������������������������������������������������������������������� 231
Configuring Debug Options�������������������������������������������������������������������������������������������������� 237
Summary���������������������������������������������������������������������������������������������������������������������������������� 238

Chapter 10: Building Applications with Python���������������������������������������������������� 239


Chapter Prerequisites��������������������������������������������������������������������������������������������������������������� 239
Creating Python Applications����������������������������������������������������������������������������������������������� 241
Running Python Code���������������������������������������������������������������������������������������������������������� 243
Code Editing Features for Python���������������������������������������������������������������������������������������������� 250
Enhanced Word Completion with IntelliSense��������������������������������������������������������������������� 250
Understanding Function Parameters with Parameter Hints������������������������������������������������ 251
Quickly Retrieving Type Definitions������������������������������������������������������������������������������������� 251
Finding References�������������������������������������������������������������������������������������������������������������� 252
Renaming Symbols�������������������������������������������������������������������������������������������������������������� 253
Finding Code Issues with Linters����������������������������������������������������������������������������������������� 254
Advanced Code Editing with Pylance���������������������������������������������������������������������������������������� 257
Managing Pylance Settings������������������������������������������������������������������������������������������������� 260
Running Python Scripts������������������������������������������������������������������������������������������������������������� 261
Summary���������������������������������������������������������������������������������������������������������������������������������� 262

Chapter 11: Deploying Applications to Azure������������������������������������������������������� 263


Introducing Azure Extensions���������������������������������������������������������������������������������������������������� 263
Deploying Web Applications������������������������������������������������������������������������������������������������������ 265
Installing Extensions������������������������������������������������������������������������������������������������������������ 265
Signing In to Azure Subscriptions���������������������������������������������������������������������������������������� 266
Publishing Web Applications������������������������������������������������������������������������������������������������ 268
Creating and Deploying Azure Functions���������������������������������������������������������������������������������� 271
Configuring Visual Studio Code������������������������������������������������������������������������������������������� 271
Creating Azure Functions����������������������������������������������������������������������������������������������������� 273
Deploying Azure Functions�������������������������������������������������������������������������������������������������� 280
x
Table of Contents

Deploying Docker Images��������������������������������������������������������������������������������������������������������� 283


Docker Prerequisites����������������������������������������������������������������������������������������������������������� 284
Creating the Application Image������������������������������������������������������������������������������������������� 285
Uploading the Application Image to a Container Registry��������������������������������������������������� 287
Deploying the Docker Image to Azure��������������������������������������������������������������������������������� 290
Summary���������������������������������������������������������������������������������������������������������������������������������� 292

Chapter 12: Consuming AI Services��������������������������������������������������������������������� 295


Introducing Azure for AI������������������������������������������������������������������������������������������������������������� 296
General Considerations������������������������������������������������������������������������������������������������������������� 297
Introducing Computer Vision����������������������������������������������������������������������������������������������� 297
Setting Up Computer Vision Services���������������������������������������������������������������������������������������� 297
Retrieving the Service Keys������������������������������������������������������������������������������������������������� 302
Consuming AI Services with .NET��������������������������������������������������������������������������������������������� 304
Setting Up Variables and Constants������������������������������������������������������������������������������������ 306
Creating Authenticated Service Clients������������������������������������������������������������������������������� 308
Executing Image Analysis���������������������������������������������������������������������������������������������������� 309
Running the Application������������������������������������������������������������������������������������������������������ 313
Consuming AI Services with JavaScript������������������������������������������������������������������������������������ 315
Setting Up Variables and Constants������������������������������������������������������������������������������������ 317
Creating Authenticated Service Clients������������������������������������������������������������������������������� 318
Executing Image Analysis���������������������������������������������������������������������������������������������������� 319
Running the Application������������������������������������������������������������������������������������������������������ 322
Consuming AI Services with Python����������������������������������������������������������������������������������������� 323
Setting Up Variables and Constants������������������������������������������������������������������������������������ 324
Creating Authenticated Service Clients������������������������������������������������������������������������������� 325
Executing Image Analysis���������������������������������������������������������������������������������������������������� 326
Running the Application������������������������������������������������������������������������������������������������������ 329
Summary���������������������������������������������������������������������������������������������������������������������������������� 330

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

Introducing Visual Studio


Code
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 in different development platforms. It
supports the application development lifecycle with a built-in debugger and integrated
support for the popular Git version control engine.
With Visual Studio Code, you can work with individual code files or with folders
containing projects or loose files. This chapter provides an introduction to Visual Studio
Code, giving you information on when and why you should use it. It includes details
about installing and configuring the program on the different supported operating
systems.

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.

 isual Studio Code, a Cross-Platform


V
Development Tool
Visual Studio Code is the first cross-platform development tool in the Microsoft Visual
Studio family that runs on Windows, Linux, and macOS. It is a free, open-source
(https://github.com/microsoft/vscode), code-centric tool. This not only makes
editing code files and folder-based project systems easier, but also facilitates writing
cross-platform web, mobile, and cloud applications in the most popular platforms, such

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.

When and Why Visual Studio Code


Before you learn how to use Visual Studio Code, explore the features it offers, and
discover 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 to make it easier to write code for web, mobile, and cloud platforms for
any developers working on Windows, Linux, or macOS, providing independence from
proprietary development environments.
For a better understanding of the nonproprietary nature of Visual Studio Code,
let’s consider an example based on ASP.NET Core, the cross-platform, open-source
technology able to run on Windows, Linux, and macOS that Microsoft produced to

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:

• Built-in support for coding in many languages, including those


you typically use in cross-platform development scenarios, such as
C# and JavaScript, 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 and Julia) via extensibility

• Version control based on the popular Git version-control system,


which provides an integrated experience for collaboration,
supporting code commits and branches

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

cannot invoke a compiler. You can work around this by implementing


task automation, discussed in Chapter 8, but this is different than
having an integrated compilation process.

• Except where provided by specific extensions, Visual Studio Code


has no designers, so you can create an application user interface
only by writing all of the related code manually. As you can imagine,
this is fine for 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 working with the powerful
graphical tools available in Microsoft Visual Studio 2022.

• Visual Studio Code 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 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.

Installing and Configuring Visual Studio Code


Installing Visual Studio Code is an easy task. In fact, you can simply visit https://
code.visualstudio.com from your favorite browser, and the web page will detect
your operating system, suggesting the appropriate installer. Figure 1-1 shows how the
download page appears on Windows.

4
Chapter 1 Introducing Visual Studio Code

Figure 1-1. The download page for 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

Installing Visual Studio Code on Windows


Visual Studio Code can be installed on Windows 8, 10, and 11. For this operating system,
Visual Studio Code is available with two installers: a global installer and a user-level
installer. The global installer requires administrative privileges for installation and
makes Code available to all users. The user-level installer makes Code available only to
the currently logged-in user, but it does not require administrative privileges.
The user-level installer 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 user-level installer. If you instead want to download the
system-level installer, go to https://code.visualstudio.com/download and select
the System Installer download that best fits your system configuration (32- or 64-bit,
or ARM).
Once the download has been completed, launch the installer and simply follow the
guided procedure that is typical of most Windows programs. During the installation, you
will be prompted to specify how you want to integrate shortcuts to Visual Studio Code
in the Windows shell. In the Select Additional Tasks dialog box, make sure you select (at
least) the following options:

• Add “Open with Code” action to Windows Explorer file context


menu, which allows you to right-click a code file in the Explorer and
open a file with VS Code.

• Add “Open with Code” action to Windows Explorer directory


context menu, which allows you to right­click a folder in the Explorer
and open 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

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.

Figure 1-2. Visual Studio Code running on Windows

7
Chapter 1 Introducing Visual Studio Code

Installing Visual Studio Code on macOS


Installing VS Code on macOS is extremely simple. From the download page, simply click
the Download for macOS button and wait for the download to complete. On macOS,
Visual Studio Code works as an individual program, and therefore you simply need to
double-click the downloaded file to start the application. Figure 1-3 shows Visual Studio
Code running on macOS.

Figure 1-3. Visual Studio Code running on macOS

8
Chapter 1 Introducing Visual Studio Code

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 need the .deb installer. For the Red Hat
Linux, Fedora, and SUSE distributions, you need the .rpm installer. This clarification is
important because, as opposed to 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.
Once Visual Studio Code is installed, simply click the Show Applications button on
the Desktop and then choose the Visual Studio Code shortcut. Figure 1-4 shows Visual
Studio Code running on Ubuntu.

9
10
Chapter 1
Introducing Visual Studio Code

Figure 1-4. Visual Studio Code running on Ubuntu


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:

> Configure Display Language

You can also just type configure display and the command will be automatically
listed in the command palette (see Figure 1-5).

Figure 1-5. Invoking the command to change the localization

Note The Command Palette is discussed thoroughly in Chapter 2.

11
Chapter 1 Introducing Visual Studio Code

When you click this command, the Command Palette displays the following options:

• English (en), which allows you to select American English as the


culture. This is the default localization and is always available.

• A list of available language packs built by Microsoft.

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.

Updating Visual Studio Code


Visual Studio Code is configured to receive automatic updates in the background;
Microsoft usually releases monthly updates.

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

Figure 1-6. Disabling automatic updates

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

Figure 1-7. 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. You can recall release notes at
any time by choosing Help ➤ Show Release Notes.

Previewing Features with Insiders Builds


By default, the download page of the Visual Studio Code’s website allows you to
download the latest stable build. However, Microsoft periodically also releases preview
builds of Visual Studio Code, called Insiders builds. You can download these Insiders
builds to look at any new and updated upcoming features before they are released to the
general public.

14
Chapter 1 Introducing Visual Studio Code

Insiders builds can be downloaded from https://code.visualstudio.com/


insiders, and they follow the same installation rules described previously for each
operating system. They have a different icon color, typically a green icon instead of a blue
icon, and the name you see in the application bar is Visual Studio Code - Insiders instead
of Visual Studio Code (see Figure 1-8).

Figure 1-8. 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 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

Visual Studio Code on Web


Microsoft is working on making Visual Studio Code available as a web application
running in your favorite browser.
This is currently available as a preview and can be reached at https://vscode.dev.
A shortcut is also available in the main site for Visual Studio Code. Figure 1-9 shows how
VS Code looks in the browser.

Figure 1-9. Visual Studio Code as a web app

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 cross­platform 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.

The Welcome Page


At startup, Visual Studio Code displays the Welcome page, as shown in Figure 2-1.

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

Figure 2-1. The Welcome page

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

The Code Editor


The code editor is certainly the area where you will spend most of your time in VS Code.
The code editor becomes available when you create a new file or open existing files and
folders. You can edit one file at a time or edit multiple files side by side concurrently.
Figure 2-2 shows an example of the latter.

Figure 2-2. The code editor and multiple file views

To do this, you have a couple options:

• Right-click a filename in the Explorer Bar and then select Open to


the Side.
• Ctrl-click a filename in the Explorer Bar. This is discussed in the
section “The Side Bar” later in this chapter.

• 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.

Reordering, Resizing, and Zooming Editor Windows


You can reorder and resize editor windows based on your preferences. To reorder an
editor, click the editor’s header (which is where you see the filename) and move the
editor to a different position. Resizing an editor can instead be accomplished by clicking
the left mouse button when the pointer is on the editor’s border, until it appears as a left/
right arrow pair.
You can also zoom in and out the environment by clicking Ctrl++ and Ctrl+-,
respectively. As an alternative, you can choose View ➤ Appearance ➤ Zoom In and View
➤ Appearance ➤ Zoom Out. You can reset the original zoom factor with Appearance ➤
Reset Zoom.

Note In Visual Studio Code, the zoom is actually an accessibility feature. As an


implication, when you zoom the code editor, everything else will also be zoomed.

The Status Bar


The Status Bar contains information about the current file or folder and provides
shortcuts for some quick actions. Figure 2-3 shows an example of how the Status Bar
appears.

Figure 2-3. The Status Bar

22
Chapter 2 Getting to Know the Environment

The Status Bar contains the following information, from left to right:

• Git version control information and options, such as the current


branch. This is only visible when VS Code is connected to a Git
repository.

• Errors and warnings detected in the source code.

• The cursor position expressed in line and column.

• Tab size, in this case Spaces: 4. You can click this to change the
indentation size and to convert indentation to tabs or spaces.

• The encoding of the current file.

• The current line terminator.

• The programming or markup language of the open file. By clicking


the current language name, you can change the language from a
drop-down list that pops up.

• The project name, if you open a folder that contains a supported


project system. It is worth noting that, if the folder contains multiple
project files, clicking this item enables you to switch between
projects.

• The Feedback button, which enables you to share your feedback


about Visual Studio Code on Twitter.

• The notification icon, which shows the number of new notifications


(if any). Notification messages typically come from extensions or they
are about product updates.

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.

The Activity Bar


The Activity Bar is on the left side of the workspace and can be considered a collapsed
container for the Side Bar. Figure 2-4 shows the Activity Bar.

23
Chapter 2 Getting to Know the Environment

Figure 2-4. The Activity Bar

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.

The Side Bar


The Side Bar is one of the most important tools in Visual Studio Code, and one of
the tools you will interact most with. It is composed of five tools, each enabled by the
corresponding icon, described in the following subsections.

The Explorer Bar


The Explorer Bar is enabled by clicking the first icon from the top of the Side Bar and
provides a structured, organized view of the folder or files you are working with. The
list of active files can be shown in the OPEN EDITORS subview. This can be enabled by

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.

Figure 2-5. The Explorer Bar

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.

The Outline View


The bottom of the Explorer Bar contains another group, called OUTLINE. This group
provides a hierarchical view of types and members defined within a code file or tags.
Figures 2-6 and 2-7 show the OUTLINE group based on a TypeScript file and based on
an HTML file, respectively.

26
Chapter 2 Getting to Know the Environment

Figure 2-6. The Outline view on a TypeScript file

27
Chapter 2 Getting to Know the Environment

Figure 2-7. The Outline view on an HTML file

You can expand types and members defined in a markup file to see what other
objects they define, and you can click each item and get the cursor over the selected item
definition in the source code. It is worth mentioning that Visual Studio Code highlights
with a different color (red in the case of the Visual Studio Light Theme) items that have
potential problems and that are highlighted with squiggles in the code editor. Currently,

28
Chapter 2 Getting to Know the Environment

the Outline view is only available to languages such as JavaScript, TypeScript, C#,
HTML, Markdown, and JSON. Support for additional languages might be available when
installing the appropriate extensions.

The Timeline View


The Timeline view shows the history of local changes made to an individual file. It only
works with code for which a local Git repository has been created.

Note The Timeline view is related to working with Git source control, the topic of
Chapter 7, but it is discussed here because it is part of the Explorer Bar. For now,
you can click the Source Control button on the Side Bar and then click the Initialize
Repository button. This initializes a local Git repository and, consequently, the
Timeline feature over individual files.

Figure 2-8 shows an example based on a file called index.html.

Figure 2-8. The Timeline view showing change history

In this particular example, the Timeline is showing three changes in the file history:
a first local commit, changes saved to disk, and staged changes. This tool is very useful
when you work with Git source control, and you want to see a detailed view of the history
for each file. Chapter 7 provides detailed explanations about integrated source control
features.

29
Chapter 2 Getting to Know the Environment

The Search Tool


The Search tool, enabled by clicking the Search icon, allows for searching and,
optionally, replacing text across files. You can search for one or more words, including
special characters (such as * and ?), and you can even search based on regular
expressions. Figure 2-9 shows the Search tool in action, with advanced options expanded
(files to include and files to exclude), which you enable by clicking the … button located
under Replace. In the example, search is performed only within .tsx files.

Figure 2-9. The Search tool

30
Chapter 2 Getting to Know the Environment

Search results are presented in a hierarchical view that groups all the files that
contain the specified search key, showing an excerpt of the line of code that contains it.
Occurrences are also highlighted in both the list of files and in the code editor. You can
finally clean up search results by clicking the Clear Search Results button located in the
toolbar close to the SEARCH header. If you instead want to replace some text with new
text, you can do this by entering the new text into the Replace text box and then clicking
the Replace All button.

Searching in the Active File


If you just need to search for contents in the active editor, you can choose Edit ➤
Find. An interactive popup allows you to type the content you want to search, and all
occurrences will be highlighted.
With large files and many occurrences of the search result, you can quickly navigate
to a specific match by enabling the Command Palette and then typing Go to Match. At
this point, you can enter the number of a match based on the search result count.
You can also choose Edit ➤ Replace if you need to make replacements in the
active editor.

The Git Bar


The Side Bar provides access to Git integration for version control. Git integration is a
core topic and is thoroughly discussed in Chapter 7, but a quick look is provided here
for the sake of completeness about the Side Bar and because the Timeline view was
discussed previously.
The Git Bar can be enabled by clicking the third button from the top of the Side
Bar (with a kind of fork icon) and provides access to all of the common source control
operations, such as initializing a repository, committing code files, and synchronizing
branches. The Git icon also shows the number of files that have been modified locally.
Figure 2-10 shows an example. Modified files are listed under the Changes group. Three
buttons are available for each listed file: Open File, Discard Changes, and Stage Changes.
In Git, as you learn in Chapter 7, the concept of staging changes means keeping changes
separate from the main code branch so that a developer can evaluate whether to commit
the changes or discard them. Clicking a filename enables a split view that shows the
differences between the modified code and the original code; this topic is also more
thoroughly discussed in Chapter 7.

31
Chapter 2 Getting to Know the Environment

Figure 2-10. The Git Bar

The Git Bar also provides a popup menu that contains the list of supported Git
commands in Visual Studio Code organized into submenus, such as Commit, Push,
Pull, and several more you discover later in the book. Click the … button in the top-right
corner of the Git Bar to open the menu.

The Run and Debug Bar


Visual Studio Code is not only a simple code editor, but also a fully featured development
tool that ships with an integrated debugger for JavaScript and .NET. It can be extended
with third-party debuggers for other platforms and languages. as well Chapter 9
describes in more detail this important part of Visual Studio Code, but for now note that
you can access the debugging tools by clicking the fourth icon from the top of the Side
Bar. This opens the Run and Debug Bar, shown in Figure 2-11.

32
Other documents randomly have
different content
pronounced by human lips,—nay, and to utter them,
when I am seemingly to blame!—yet, believe me, my
silence is not owing to negligence, or to that most wicked
of all sins, inconstancy. I have thought on you waking or
sleeping, whenever I have thought at all, from the
moment I saw you last; and if there was an echo in the
neighbourhood besides Mr. Cambridge, I should have
made it repeat your Ladyship’s name, till the parish
should have presented it for a nuisance. I have begun
twenty letters, but the naked truth is, I found I had
absolutely nothing to say. You yourself owned, Madam,
that I am grown quite lifeless, and it is very true. I am
none of your Glastonbury thorns that blow at Christmas. I
am a remnant of the last age, and have nothing to do
with the present. I am an exile from the sunbeams of
drawing-rooms; I have quitted the gay scenes of
Parliament and the Antiquarian Society; I am not of
Almack’s; I don’t understand horse-races; I never go to
reviews; what can I have to talk of? I go to no fêtes
champêtres, what can I have to think of? I know nothing
but about myself, and about myself I know nothing. I
have scarce been in town since I saw you, have scarce
seen anybody here, and don’t remember a tittle but
having scolded my gardener twice, which, indeed, would
be as important an article as any in Montaigne’s Travels,
which I have been reading, and if I was tired of his
Essays, what must one be of these! What signifies what a
man thought, who never thought of anything but himself;
and what signifies what a man did, who never did
anything?”

In August, hearing that Lady Ossory had again been disappointed of a


son, he tells her: “I don’t design to acknowledge Anne III.; I shall call
her Madame de Trop, as they named one of the late King of France’s
daughters. A dauphin! a dauphin! I will repeat it as often as the Graces.”
A month later he is informed that Madame de Trop has received the
name of Gertrude:
“Madam,—‘Methinks an Æsop’s fable you relate,’ as
Dryden says in the ‘Hind and Panther.’ A mouse that
wraps itself in a French cloak and sleeps on a couch; and
a goldfinch that taps at the window and swears it will
come in to quadrille at eleven o’clock at night! no, no,
these are none of Æsop’s cattle; they are too fashionable
to have lived so near the creation. The mouse is neither
Country Mouse nor City Mouse; and whatever else he
may be, the goldfinch must be a Macaroni, or at least of
the Sçavoir vivre. I do not deny but I have some skill in
expounding types and portents; and could give a shrewd
guess at the identical persons who have travestied
themselves into a quadruped and biped; but the truth is, I
have no mind, Madam, to be Prime Minister. King Pharaoh
is mighty apt on emergencies to send for us soothsayers,
and put the whole kingdom into our hands, if his butler or
baker, with whom he is wont to gossip, does but tell him
of a cunning man.
“I have no ambition to supplant Lord North—especially
as the season approaches when I dread the gout; and I
should be very sorry to be fetched out of my bed to pacify
America. To be sure, Madam, you give me a fair field for
uttering oracles: however, all I will unfold is, that the
emblematic animals have no views on Lady Louisa.[61]
The omens of her fortune are in herself; and I will burn
my books, if beauty, sense, and merit, do not bestow all
the happiness on her they prognosticate.…
“I like the blue eyes, Madam, better than the
denomination of Lady Gertrude Fitzpatrick, which, all
respectable as it is, is very harsh and rough sounding;
pray let her change it with the first goldfinch that offers.
Nay, I do not even trust to the blueth of the eyes. I do
not believe they last once in twenty times. One cannot go
into any village fifty miles from London without seeing a
dozen little children with flaxen hair and eyes of sky-blue.
What becomes of them all? One does not see a grown
Christian with them twice in a century, except in poetry.
“The Strawberry Gazette is very barren of news. Mr.
Garrick has the gout, which is of more consequence to
the metropolis than to Twitnamshire. Lady Hertford dined
here last Saturday, brought her loo party, and stayed
supper; there were Lady Mary Coke, Mrs. Howe, and the
Colonels Maude and Keene. This was very heroic, for one
is robbed every hundred yards. Lady Hertford herself was
attacked last Wednesday on Hounslow Heath at three in
the afternoon, but she had two servants on horseback,
who would not let her be robbed, and the highwayman
decamped.
“The greatest event I know was a present I received
last Sunday, just as I was going to dine at Lady
Blandford’s, to whom I sacrificed it. It was a bunch of
grapes as big—as big—as that the two spies carried on a
pole to Joshua; for spies in those days, when they robbed
a vineyard, were not at all afraid of being overtaken. In
good truth, this bunch weighed three pounds and a half,
côte rôtie measure; and was sent to me by my neighbour
Prado, of the tribe of Issachar, who is descended from
one of foresaid spies, but a good deal richer than his
ancestor. Well, Madam, I carried it to the Marchioness of
Blandford, but gave it to the maître d’hotel, with
injunctions to conceal it till the dessert. At the end of
dinner, Lady Blandford said, she had heard of three
immense bunches of grapes at Mr. Prado’s, at a dinner he
had made for Mr. Welbore Ellis. I said those things were
always exaggerated. She cried, Oh! but Mrs. Ellis told it,
and it weighed I don’t know how many pounds, and the
Duke of Argyll had been to see the hothouse, and she
wondered, as it was so near, I would not go and see it.
Not I, indeed, said I; I dare to say there is no curiosity in
it. Just then entered the gigantic bunch. Everybody
screamed. There, said I, I will be shot if Mr. Prado has
such a bunch as yours. In short, she suspected Lady
Egremont, and the adventure succeeded to admiration. If
you will send the Bedfordshire waggon, Madam, I will beg
a dozen grapes for you.…
“Pray, Madam, is not it Farming-Woods’ tide?[62] Who is
to have the care of the dear mouse in your absence? I
wish I could spare Margaret [his housekeeper], who loves
all creatures so well that she would have been happy in
the Ark, and sorry when the Deluge ceased; unless
people had come to see Noah’s old house, which she
would have liked still better than cramming his
menagerie.”
Sir Joshua Reynolds. Pinx. A. Dawson. Ph. Sc. J. Raphael
Smith. Sc.

Lady Gertrude Fitzpatrick.


The dearth of news was presently relieved by a General Election,
about which and other topics Walpole writes to Mann:
“Strawberry Hill, Oct. 6, 1774.
“It would be unlike my attention and punctuality, to see
so large an event as an irregular dissolution of Parliament,
without taking any notice of it to you. It happened last
Saturday, six months before its natural death, and without
the design being known but the Tuesday before, and that
by very few persons. The chief motive is supposed to be
the ugly state of North America, and the effects that a
cross winter might have on the next elections. Whatever
were the causes, the first consequences, as you may
guess, were such a ferment in London as is seldom seen
at this dead season of the year. Couriers, despatches,
post-chaises, post-horses, hurrying every way! Sixty
messengers passed through one single turnpike on Friday.
The whole island is by this time in equal agitation; but
less wine and money will be shed than have been at any
such period for these fifty years.…
“The first symptoms are not favourable to the Court;
the great towns are casting off submission, and declaring
for popular members. London, Westminster, Middlesex,
seem to have no monarch but Wilkes, who is at the same
time pushing for the Mayoralty of London, with hitherto a
majority on the poll. It is strange how this man, like a
phœnix, always revives from his embers! America, I
doubt, is still more unpromising. There are whispers of
their having assembled an armed force, and of earnest
supplications arrived for succours of men and ships. A
civil war is no trifle; and how we are to suppress or
pursue in such a vast region, with a handful of men, I am
not an Alexander to guess; and for the fleet, can we put it
upon casters and wheel it from Hudson’s Bay to Florida?
But I am an ignorant soul, and neither pretend to
knowledge nor foreknowledge. All I perceive already is,
that our Parliaments are subjected to America and India,
and must be influenced by their politics; yet I do not
believe our senators are more universal than formerly.
“It would be quite unfashionable to talk longer of
anything but elections; and yet it is the topic on which I
never talk or think, especially since I took up my freedom.
[63]…

“In the midst of this combustion, we are in perils by


land and water. It has rained for this month without
intermission. There is a sea between me and Richmond,
and Sunday was se’nnight I was hurried down to
Isleworth in the ferryboat by the violence of the current,
and had great difficulty to get to shore. Our roads are so
infested by highwaymen, that it is dangerous stirring out
almost by day. Lady Hertford was attacked on Hounslow
Heath at three in the afternoon. Dr. Eliot was shot at
three days ago, without having resisted; and the day
before yesterday we were near losing our Prime Minister,
Lord North; the robbers shot at the postilion, and
wounded the latter. In short, all the freebooters, that are
not in India, have taken to the highway. The Ladies of the
Bedchamber dare not go to the Queen at Kew in an
evening. The lane between me and the Thames is the
only safe road I know at present, for it is up to the middle
of the horses in water. Next week I shall not venture to
London even at noon, for the Middlesex election is to be
at Brentford, where the two demagogues, Wilkes and
Townshend, oppose each other; and at Richmond there is
no crossing the river. How strange all this must appear to
you Florentines; but you may turn to your Machiavelli and
Guicciardini, and have some idea of it. I am the quietest
man at present in the whole island; not but I might take
some part, if I would. I was in my garden yesterday,
seeing my servants lop some trees; my brewer walked in
and pressed me to go to Guildhall for the nomination of
members for the county. I replied, calmly, ‘Sir, when I
would go no more to my own election, you may be very
sure I will go to that of nobody else.’ My old tune is,

“‘Suave mari magno turbantibus æquora ventis,’ &c.

“Adieu!
“P.S. Arlington Street, 7th.
“I am just come to town, and find your letter.… The
approaching death of the Pope will be an event of no
consequence. That old mummery is near its conclusion, at
least as a political object. The history of the latter Popes
will be no more read than that of the last
Constantinopolitan Emperors. Wilkes is a more
conspicuous personage in modern story than the Pontifex
Maximus of Rome. The poll for Lord Mayor ended last
night; he and his late Mayor had above 1,900 votes, and
their antagonists not 1,500. It is strange that the more he
is opposed, the more he succeeds!”

The foregoing is an average sample of the bulk of Walpole’s Letters to


Sir Horace Mann. It was to these Macaulay referred when he said,
sneeringly, that Walpole “left copies of his private letters, with copious
notes, to be published after his decease.” There can be no doubt that
their author regarded them as a valuable contribution to the history of
his times. And such, in truth, they were. Many of them contain full
details of some political movement, written by one who, if not himself
engaged in the struggle, was in close communication with the actors on
one side at least. Hence, though these letters may be loaded with bias,
they are often of solid substance. If they are not equally important for
our present purpose, this is because they deal almost entirely with
public matters and with the general news of the day. “Nothing is so
pleasant in a letter,” writes Walpole to Lady Ossory, “as the occurrences
of society. I am always regretting in my correspondence with Madame
du Deffand and Sir Horace Mann, that I must not make use of them, as
the one has never lived in England, and the other not these fifty years;
and so, my private stories would want notes as much as Petronius. Sir
Horace and I have no acquaintance in common but the Kings and
Queens of Europe.”
In a letter to Mann, dated November 24, 1774, Walpole returns to the
subject of the new Parliament:
“A great event happened two days ago—a political and
moral event; the sudden death of that second Kouli Khan,
Lord Clive. There was certainly illness in the case; the
world thinks more than illness. His constitution was
exceedingly broken and disordered, and grown subject to
violent pains and convulsions. He came unexpectedly to
town last Monday, and they say, ill. On Tuesday his
physician gave him a dose of laudanum, which had not
the desired effect. On the rest, there are two stories; one,
that the physician repeated the dose; the other, that he
doubled it himself, contrary to advice.[64] In short, he has
terminated at fifty a life of so much glory, reproach, art,
wealth, and ostentation! He had just named ten members
for the new Parliament.[65]
“Next Tuesday that Parliament is to meet—and a deep
game it has to play! few Parliaments a greater. The world
is in amaze here that no account is arrived from America
of the result of their General Congress—if any is come, it
is very secret; and that has no favourable aspect. The
combination and spirit there seem to be universal, and is
very alarming. I am the humble servant of events, and
you know never meddle with prophecy. It would be
difficult to descry good omens, be the issue what it will.
“The old French Parliament is restored with great éclat.
Monsieur de Maurepas, author of the revolution, was
received one night at the Opera with boundless shouts of
applause. It is even said that the mob intended, when the
King should go to hold the lit de justice, to draw his
coach. How singular it would be if Wilkes’s case should be
copied for a King of France! Do you think Rousseau was
in the right, when he said that he could tell what would
be the manners of any capital city, from certain given
lights? I don’t know what he may do on Constantinople
and Pekin—but Paris and London! I don’t believe Voltaire
likes these changes. I have seen nothing of his writing for
many months; not even on the poisoning Jesuits.[66] For
our part, I repeat it, we shall contribute nothing to the
Histoire des Mœurs, not for want of materials, but for
want of writers. We have comedies without novelty, gross
satires without stings, metaphysical eloquence, and
antiquarians that discover nothing.

“‘Bœotûm in crasso jurares aere natos!’

“Don’t tell me I am grown old and peevish and


supercilious—name the geniuses of 1774, and I submit.
The next Augustan age will dawn on the other side of the
Atlantic. There will, perhaps, be a Thucydides at Boston,
a Xenophon at New York, and, in time, a Virgil at Mexico,
and a Newton at Peru. At last, some curious traveller from
Lima will visit England, and give a description of the ruins
of St. Paul’s, like the editions of Balbec and Palmyra; but
am I not prophesying, contrary to my consummate
prudence, and casting horoscopes of empires like
Rousseau? Yes; well, I will go and dream of my visions.”

More than one writer has cited Walpole’s traveller from Lima as the
original of Lord Macaulay’s traveller from New Zealand, who, in the
midst of a vast solitude, takes his stand on a broken arch of London
Bridge to sketch the ruins of St. Paul’s. Others have traced the passage
in the celebrated Review of Ranke’s “History of the Popes,” to Volney,
Mrs. Barbauld, Kirke White, and Shelley; while others again have
pointed out that, from whatsoever source derived, the idea expressed in
this passage had been twice before employed by Macaulay, once, in
1824, in a Review of Mitford’s “Greece,” and the second time, in 1829, in
his Review of Mill’s “Essay on Government.” The picture of the New
Zealander, however, resembles the less ambitious, but equally graphic,
figure of the traveller from Lima more closely than it does any of the
other passages referred to.[67] What is remarkable is, that the Review of
Ranke’s “History” appeared in October, 1840, whereas the later portion
of Walpole’s correspondence with Mann, to which the above extract
belongs, was first published from the original manuscripts in 1843. How
then could Macaulay know anything of the Peruvian stranger?[68]
The following was also addressed to Sir H. Mann. It is dated in May,
1775:
“You have not more Masquerades in Carnival than we
have; there is one at the Pantheon to-night, another on
Monday; and in June is to be a pompous one on the
water, and at Ranelagh. This and the first are given by
the Club called the Sçavoir Vivre, who till now have only
shone by excess of gaming. The leader is that fashionable
orator Lord Lyttelton,[69] of whom I need not tell you
more. I have done with these diversions, and enjoy
myself here. Your old acquaintance, Lord and Lady Dacre,
and your old friend, Mr. Chute, dined with me to-day:
poor Lord Dacre[70] is carried about, though not worse
than he has been these twenty years. Strawberry was in
great beauty; what joy I should have in showing it to you!
Is this a wish I must never indulge? Alas!
“I have had a long chain of thoughts since I wrote the
last paragraph. They ended in smiling at the word never.
How one pronounces it to the last moment! Would not
one think I counted on a long series of years to come?
Yet no man has the termination of all his views more
before his eyes, or knows better the idleness of framing
visions to one’s self. One passes away so soon, and
worlds succeed to worlds, in which the occupiers build the
same castles in the air. What is ours but the present
moment? And how many of mine are gone! And what do
I want to show you? A plaything-vision, that has amused
a poor transitory mortal for a few hours, and that will
pass away like its master! Well, and yet is it not as
sensible to conform to common ideas, and to live while
one lives? Perhaps the wisest way is to cheat one’s self.
Did one concentre all one’s thoughts on the nearness and
certainty of dissolution, all the world would lie eating and
sleeping like the savage Americans. Our wishes and views
were given us to gild the dream of life, and if a
Strawberry Hill can soften the decays of age, it is wise to
embrace it, and due gratitude to the Great Giver to be
happy with it. The true pain is the reflection on the
numbers that are not so blessed; yet I have no doubt but
the real miseries of life—I mean those that are unmerited
and unavoidable,—will be compensated to the sufferers.
Tyrants are a proof of an hereafter. Millions of men cannot
be formed for the sport of a cruel child.
“How happy is the Pretender in missing a Crown! When
dead, he will have all the advantage that other Kings
have, the being remembered; and that greater
advantage, which Kings who die in their childhood have,
historians will say, he would have been a great King if he
had lived to reign; and that greatest advantage which so
very few of them have, his reign will be stained with no
crimes and blunders. If he is at Florence, pray
recommend me to him for his historian; you see I have all
the qualities a Monarch demands, I am disposed to flatter
him. You may tell him too what I have done for his uncle
Richard III. The mischief is in it, if I am not qualified for a
Royal Historiographer, when I have whitewashed one of
the very few whom my brethren, so contrary to their
custom, have agreed to traduce.”

In the autumn of 1775, Walpole was in Paris, whence he sends, for


the benefit of Conway’s daughter, this important piece of information:
“Tell Mrs. Damer, that the fashion now is to erect the toupée into a high
detached tuft of hair, like a cockatoo’s crest; and this toupée they call la
physionomie—I don’t guess why.” And in giving George Selwyn an
account of the modish French ladies whom he met, he adds a
description suited to the humour of that facetious gentleman: “With one
of them,” he says, “you would be delighted, a Madame de Marchais. She
is not perfectly young, has a face like a Jew pedlar, her person is about
four feet, her head about six, and her coiffure about ten. Her forehead,
chin, and neck are whiter than a miller’s; and she wears more festoons
of natural flowers than all the figurantes at the Opera. Her eloquence is
still more abundant, her attentions exuberant. She talks volumes, writes
folios—I mean in billets; presides over the Académie, inspires
passions.… She has a house in a nut-shell, that is fuller of invention than
a fairy tale; her bed stands in the middle of the room, because there is
no other space that would hold it; it is surrounded by a perspective of
looking-glasses.…” In reference to the rage for billets, he mentions “a
collection that was found last winter at Monsieur de Pondeveylle’s: there
were sixteen thousand from one lady, in a correspondence of only
eleven years. For fear of setting the house on fire if thrown into the
chimney, the executors crammed them into the oven.” “There have been
known,” he adds, “persons here who wrote to one another four times a
day; and I was told of one couple, who being always together, and the
lover being fond of writing, he placed a screen between them, and then
wrote to Madam on t’other side, and flung them over.” Of his “dear old
friend,” he reports:
“Madame du Deffand has been so ill, that the day she
was seized I thought she would not live till night. Her
Herculean weakness, which could not resist strawberries
and cream after supper, has surmounted all the ups and
downs which followed her excess; but her impatience to
go everywhere and to do everything has been attended
with a kind of relapse, and another kind of giddiness; so
that I am not quite easy about her, as they allow her to
take no nourishment to recruit, and she will die of
inanition, if she does not live upon it. She cannot lift her
head from the pillow without étourdissemens; and yet her
spirits gallop faster than anybody’s, and so do her
repartees. She has a great supper to-night for the Duc de
Choiseul, and was in such a passion yesterday with her
cook about it, and that put Tonton[71] into such a rage,
that nos dames de Saint Joseph thought the devil or the
philosophers were flying away with their convent! As I
have scarce quitted her, I can have had nothing to tell
you. If she gets well, as I trust, I shall set out on the
12th; but I cannot leave her in any danger—though I
shall run many myself, if I stay longer. I have kept such
bad hours with this malade, that I have had alarms of
gout; and bad weather, worse inns, and a voyage in
winter, will ill suit me.…
“I must repose a great while after all this living in
company; nay, intend to go very little into the world
again, as I do not admire the French way of burning one’s
candle to the very snuff in public.”

At the end of 1775, Sir Horace Mann’s elder brother died, the family
estate came to the Ambassador, and Walpole flattered himself “that a
regular correspondence of thirty-four years will cease, and that I shall
see him again before we meet in the Elysian fields.” He was
disappointed. In February, 1776, he writes to his old friend: “You have
chilled me so thoroughly by the coldness of your answer, and by the
dislike you express to England, that I shall certainly press you no more
to come. I thought at least it would have cost you a struggle.” Again, a
little later: “Pray be assured, I acquiesce in all you say on your own
return, though grieved at your resolution, and more so at the necessity
you find in adhering to it. It is not my disposition to prefer my own
pleasure to the welfare of my friends. Your return might have opened a
warm channel of affection which above thirty years could not freeze; but
I am sure you know my steadiness too well to suspect me of cooling to
you, because we are both grown too old to meet again. I wished that
meeting as a luxury beyond what old age often tastes; but I am too well
prepared for parting with everything to be ill-humouredly chagrined
because one vision fails.” In July, 1776, we find the following, also
addressed to Mann:
“I did flatter myself with being diverted at your surprise
from so general an alteration of persons, objects,
manners, as you would have found; but there is an end of
all that pleasing vision! I remember when my father went
out of place, and was to return visits, which Ministers are
excused from doing, he could not guess where he was,
finding himself in so many new streets and squares. This
was thirty years ago. They have been building ever since,
and one would think they had imported two or three
capitals. London could put Florence into its fob-pocket;
but as they build so slightly, if they did not rebuild, it
would be just the reverse of Rome, a vast circumference
of city surrounding an area of ruins. As its present
progress is chiefly north, and Southwark marches south,
the metropolis promises to be as broad as long. Rows of
houses shoot out every way like a polypus; and, so great
is the rage of building everywhere, that, if I stay here a
fortnight, without going to town, I look about to see if no
new house is built since I went last. America and France
must tell us how long this exuberance of opulence is to
last! The East Indies, I believe, will not contribute to it
much longer. Babylon and Memphis and Rome, probably,
stared at their own downfall. Empires did not use to
philosophise, nor thought much but of themselves. Such
revolutions are better known now, and we ought to
expect them—I do not say we do. This little island will be
ridiculously proud some ages hence of its former brave
days, and swear its capital was once as big again as Paris,
or—what is to be the name of the city that will then give
laws to Europe?—perhaps New York or Philadelphia.”

At the close of 1776, Walpole had another severe illness. It is first


mentioned in a letter to Lady Ossory:
“It is not from being made Archbishop of York, that I
write by a secretary [Kirgate], Madam; but because my
right hand has lost its cunning. It has had the gout ever
since Friday night, and I am overjoyed with it, for there is
no appearance of its going any farther. I came to town on
Sunday in a panic, concluding I should be bedrid for three
months, but I went out last night, and think I shall be
able in a few days to play upon the guitar if I could play
upon it at all.…
“I have seen the picture of ‘St. George,’ and approve
the Duke of Bedford’s head, and the exact likeness of
Miss Vernon,[72] but the attitude is mean and foolish, and
expresses silly wonderment. But of all, delicious is a
picture of a little girl of the Duke of Buccleuch, who is
overlaid with a long cloak, bonnet, and muff, in the midst
of the snow, and is perishing blue and red with cold, but
looks so smiling, and so good-humoured, that one longs
to catch her up in one’s arms and kiss her till she squalls.
“My hand has not a word more to say.”

Sir Joshua Reynolds. Pinx. A. Dawson. Ph. Sc. J. Raphael


Smith. Sc.

Lady Caroline Montagu.


The attack proved obstinate, and we have again complaints of the
English climate, mixed with lamentations over the change in English
manners. Thus in February, 1777, he writes:
“Everything is changed; as always must happen when
one grows old, and is prejudiced to one’s old ways. I do
not like dining at nearly six, nor beginning the evening at
ten at night. If one does not conform, one must live
alone; and that is more disagreeable and more difficult in
town than in the country, where old useless people ought
to live. Unfortunately, the country does not agree with
me; and I am sure it is not fancy; for my violent partiality
to Strawberry Hill cannot be imposed upon. I am
persuaded that it is the dampness of this climate that
gives me so much gout; and London, from the number of
fires and inhabitants, must be the driest spot in the
nation.”

The following, written to Lord Nuneham in July, is in a gayer tone:


“Now I have taken this liberty, my dear Lord, I must
take a little more; you know my old admiration and envy
are your garden. I do not grudge Pomona or Sir James
Cockburn their hot-houses, nor intend to ruin myself by
raising sugar and water in tanner’s bark and peach skins.
The Flora Nunehamica is the height of my ambition, and if
your Linnæus should have any disciple that would
condescend to look after my little flower-garden, it would
be the delight of my eyes and nose, provided the
cataracts of heaven are ever shut again! Not one proviso
do I make, but that the pupil be not a Scot. We had
peace and warm weather before the inundation of that
northern people, and therefore I beg to have no Attila for
my gardener.
“Apropos, don’t your Lordship think that another set of
legislators, the Maccaronis and Maccaronesses, are very
wise? People abuse them for turning days, nights, hours
and seasons topsy-turvy; but surely it was upon mature
reflection. We had a set of customs and ideas borrowed
from the continent that by no means suited our climate.
Reformers bring back things to their natural course.
Notwithstanding what I said in spite in the paragraph
above, we are in truth but Greenlanders, and ought to
conform to our climate. We should lay in store of
provisions and candles and masquerades and coloured
lamps for ten months in the year, and shut out our
twilight and enjoy ourselves. In September and October,
we may venture out of our ark, and make our hay, and
gather in our corn, and go to horse-races, and kill
pheasants and partridges for stock for our winter’s
supper. I sailed in a skiff and pair this morning to Lady
Cecilia Johnston, and found her, like a good housewife,
sitting over her fire, with her cats and dogs and birds and
children. She brought out a dram to warm me and my
servants, and we were very merry and comfortable. As
Lady Nuneham has neither so many two-footed or four-
footed cares upon her hands, I hope her hands have been
better employed.
“I wish I could peep over her shoulder one of these wet
mornings!”
CHAPTER VII.
The American War.—Irish Discontent.—Want of Money.—The
Houghton Pictures Sold.—Removal to Berkeley Square.—Ill-
health.—A Painting by Zoffani.—The Rage for News.—The Duke
of Gloucester.—Wilkes.—Fashions, Old and New.—Mackerel News.
—Pretty Stories.—Madame de Sévigné’s Cabinet.—Picture of his
Waldegrave Nieces.—The Gordon Riots.—Death of Madame du
Deffand.—The Blue Stockings.

Humourist as he was, and too often swayed by prejudice, no man had


a sounder judgment than Walpole when he gave his reason fair play. In
his estimate of public events, he sometimes displayed unusual sagacity.
Though his dislike of Lord Chatham led him to disparage the efforts of
the old man eloquent to avert the American War—efforts which filled
Franklin with admiration—he yet foresaw quite as clearly as Chatham
the disastrous results of that contest. The celebrated speeches which fell
dead on the ear of Parliament had no more effect upon Walpole; but
Walpole did not need to be moved by them, for he was convinced
already. “This interlude,” he writes to Conway, who was then in Paris,
“would be entertaining, if the scene was not so totally gloomy. The
Cabinet have determined on civil war.… There is food for meditation!
Will the French you converse with be civil and keep their countenances?
Pray remember it is not decent to be dancing at Paris, when there is a
civil war in your own country. You would be like the country squire, who
passed by with his hounds as the battle of Edgehill began.” The letter in
which these words occur is dated January 22, 1775. Three weeks later,
the writer adds: “The war with our Colonies, which is now declared, is a
proof how much influence jargon has on human actions. A war on our
own trade is popular![73] Both Houses are as eager for it as they were
for conquering the Indies—which acquits them a little of rapine, when
they are as glad of what will impoverish them as of what they fancied
was to enrich them.” His sympathy, as well as his judgment, was on the
side of the Colonies. On September 7th, 1775, he writes to Mann: “You
will not be surprised that I am what I always was, a zealot for liberty in
every part of the globe, and consequently that I most heartily wish
success to the Americans. They have hitherto not made one blunder;
and the Administration have made a thousand, besides the two capital
ones, of first provoking, and then of uniting the Colonies. The latter
seem to have as good heads as hearts, as we want both.” And on the
11th: “The Parliament is to meet on the 20th of next month, and vote
twenty-six thousand seamen! What a paragraph of blood is there! With
what torrents must liberty be preserved in America! In England what
can save it?… What prospect of comfort has a true Englishman? Why,
that Philip II. miscarried against the boors of Holland, and that Louis
XIV. could not replace James II. on the throne!” And when Fortune
declared herself on the side of the Colonists, Horace, unmoved by the
reverses of his country, steadily preserved the same tone. “We have
been horribly the aggressors,” he wrote at the end of 1777, “and I must
rejoice that the Americans are to be free, as they had a right to be, and
as I am sure they have shown they deserve to be.” But the calamities
and disgraces of the time weighed heavily on his spirits. His
correspondence throughout 1777 and the two following years is full of
the American War. He recurs to the subject again and again, and harps
upon it continually. It does not fall within our plan to quote his criticisms
and reflections on the conduct of Lord North and his opponents. They
are generally as acute and sensible as they are always vigorous and
lively. The chief mistake one remarks in them is, that they assume the
victory of America to mean the ruin of England’s Empire. The writer saw
British troops everywhere defeated, retreating, laying down their arms;
France allying herself with the rebellious Colonies, and threatening
England with invasion; Spain joining in the hostile league; and Ireland
showing fresh signs of disaffection: what wonder if he was tempted to
predict that we should “moulder piecemeal into our insignificant
islandhood?” In May, 1779, he writes: “Our oppressive partiality to two
or three manufacturing towns in England has revolted the Irish, and
they have entered into combinations against purchasing English goods
in terms more offensive than the first associations of the Colonies. In
short, we have for four or five years displayed no alacrity or address, but
in provoking our friends and furnishing weapons of annoyance to our
enemies; and the unhappy facility with which the Parliament has
subscribed to all these oversights has deceived the Government into
security, and encouraged it to pull almost the whole fabric on its own
head. We can escape but by concessions and disgrace; and when we
attain peace, the terms will prove that Parliamentary majorities have
voted away the wisdom, glory, and power of the nation.”
Before the date of this extract, the pressure of the war had made
itself felt in English society. In the preceding summer, Horace had
written to Mason, then engaged on his poem of “The English Garden”:
“Distress is already felt; one hears of nothing but of the
want of money; one sees it every hour. I sit in my Blue
window, and miss nine in ten of the carriages that used to
pass before it. Houses sell for nothing, which, two years
ago, nabobs would have given lacs of diamonds for. Sir
Gerard Vanneck’s house and beautiful terrace on the
Thames, with forty acres of ground, and valued by his
father at twenty thousand pounds, was bought in last
week at six thousand. Richmond is deserted; an hundred
and twenty coaches used to be counted at the church-
door—there are now twenty. I know nobody that grows
rich but Margaret. This Halcyon season has brought her
more customers than ever, and were anything to happen
to her, I have thoughts, like greater folk, of being my own
minister, and showing my house myself. I don’t wonder
your Garden has grown in such a summer, and I am glad
it has, that our taste in gardening may be immortal in
verse, for I doubt it has seen its best days! Your poem
may transplant it to America, whither our best works will
be carried now, as our worst used to be. Do not you feel
satisfied in knowing you shall be a classic in a free and
rising empire? Swell all your ideas, give a loose to all your
poetry; your lines will be repeated on the banks of the
Orinoko; and which is another comfort, Ossian’s ‘Dirges’
will never be known there. Poor Strawberry must sink in
fæce Romuli; that melancholy thought silences me.”

Besides being vexed at the state of public affairs, Walpole suffered


much about this time from the gout, and from family troubles. His
nephew, Lord Orford, having recovered from a second attack of insanity,
resolved on selling the pictures at Houghton. In February, 1779, Horace
writes to Lady Ossory: “The pictures at Houghton, I hear, and I fear, are
sold: what can I say? I do not like even to think on it. It is the most
signal mortification to my idolatry for my father’s memory, that it could
receive. It is stripping the temple of his glory and of his affection. A
madman excited by rascals has burnt his Ephesus. I must never cast a
thought towards Norfolk more; nor will hear my nephew’s name if I can
avoid it. Him I can only pity; though it is strange he should recover any
degree of sense, and never any of feeling!” The transaction was not, in
fact, at that moment concluded. In the course of the same year,
however, the whole gallery was sold to the Empress of Russia for a little
more than forty thousand pounds. Walpole did not think the bargain a
bad one, though he would rather, he said, the pictures were sold to the
Crown of England than to that of Russia, where they would be burnt in a
wooden palace on the first insurrection, while in England they would still
be Sir Robert Walpole’s Collection. “But,” he added, “my grief is that
they are not to remain at Houghton, where he placed them and wished
them to remain.”
While grieving over his father’s pictures, Horace found himself
involved in a Chancery suit. The lease of his town house in Arlington
Street running out about this time, he had bought a larger house in
Berkeley Square. Difficulties, however, hindered the completion of the
purchase, and the affair went into Chancery. Fortunately, under
Walpole’s management, the suit became a friendly one. “I have
persisted in complimenting and flattering my parties, till by dint of
complaisance and respect I have brought them to pique themselves on
equal attentions; so that, instead of a lawsuit, it has more the air of a
treaty between two little German princes who are mimicking their
betters only to display their titular dignities. His Serene Highness,
Colonel Bishopp, is the most obsequious and devoted servant of my
Serenity the Landgrave of Strawberry.” The judge was equally agreeable.
“Yesterday I received notice from my attorney that the Master of the
Rolls has, with epigrammatic despatch, heard my cause, and
pronounced a decree in my favour. Surely, the whip of the new driver,
Lord Thurlow, has pervaded all the hard wheels of the law, and set them
galloping. I must go to town on Monday, and get my money ready for
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.

More than just a book-buying platform, we strive to be a bridge


connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.

Join us on a journey of knowledge exploration, passion nurturing, and


personal growth every day!

ebookmasss.com

You might also like