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

Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux 3 / converted Edition Alessandro Del Sole instant download

The document promotes the book 'Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux' by Alessandro Del Sole, which serves as a comprehensive guide for developers to utilize Visual Studio Code for cross-platform application development. It covers installation, customization, and various coding features, along with source control and debugging techniques. The book aims to enhance the coding experience across multiple operating systems and programming languages.

Uploaded by

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

Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux 3 / converted Edition Alessandro Del Sole instant download

The document promotes the book 'Visual Studio Code Distilled: Evolved Code Editing for Windows, macOS, and Linux' by Alessandro Del Sole, which serves as a comprehensive guide for developers to utilize Visual Studio Code for cross-platform application development. It covers installation, customization, and various coding features, along with source control and debugging techniques. The book aims to enhance the coding experience across multiple operating systems and programming languages.

Uploaded by

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

Download the full version and explore a variety of ebooks

or textbooks at https://ebookmass.com

Visual Studio Code Distilled: Evolved Code Editing


for Windows, macOS, and Linux 3 / converted
Edition Alessandro Del Sole

_____ Tap the link below to start your download _____

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

Find ebooks or textbooks at ebookmass.com today!


Here are some recommended products for you. Click the link to
download, or explore more at ebookmass.com

Visual Studio Code Distilled: Evolved Code Editing for


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

3-2-1 Code It! 7th Edition

https://ebookmass.com/product/3-2-1-code-it-7th-edition/

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/
Alessandro Del Sole

Visual Studio Code Distilled


Evolved Code Editing for Windows, macOS, and
Linux
3rd ed.
Alessandro Del Sole
Cremona, Italy

ISBN 978-1-4842-9483-3 e-ISBN 978-1-4842-9484-0


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

© Alessandro Del Sole 2019, 2021, 2023

This work is subject to copyright. All rights are solely and exclusively
licensed 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.

The use of general descriptive names, registered names, trademarks, service


marks, etc. in this publication does not imply, even in the absence of a
specific statement, that such names are exempt from the relevant protective
laws and regulations and therefore free for general use.

The publisher, the authors, and the editors are safe to assume that the advice
and information in this book are believed to be true and accurate at the date
of publication. Neither the publisher nor the authors or the editors give a
warranty, expressed or implied, with respect to the material contained
herein or for any errors or omissions that may have been made. The
publisher remains neutral with regard to jurisdictional claims in published
maps and institutional affiliations.

This Apress imprint is published by the registered company APress Media,


LLC, part of Springer Nature.
The registered company address is: 1 New York Plaza, New York, NY
10004, U.S.A.
To my wonderful wife, Angelica. You are my reason to live.
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.
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.
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.
Table of Contents
Chapter 1:​Introducing Visual Studio Code
Visual Studio Code, a Cross-Platform Development Tool
When and Why Visual Studio Code
Installing and Configuring Visual Studio Code
Installing Visual Studio Code on Windows
Installing Visual Studio Code on macOS
Installing Visual Studio Code on Linux
Localization Support
Updating Visual Studio Code
Previewing Features with Insiders Builds
Visual Studio Code on Web
Summary
Chapter 2:​Getting to Know the Environment
The Welcome Page
The Code Editor
Reordering, Resizing, and Zooming Editor Windows
The Status Bar
The Activity Bar
The Side Bar
The Explorer Bar
The Search Tool
The Git Bar
The Run and Debug Bar
The Extensions Bar
The Accounts Button
The Settings Button
Navigating Between Files
The Command Palette
The Panels Area
The Problems Panel
The Output Panel
The Debug Console Panel
Working with the Terminal
Summary
Chapter 3:​Language Support and Code Editing Features
Language Support
Working with C# and C++
Working with Python
Working with Julia
Working with Go
Basic Code Editing Features
Working with Text
Syntax Colorization
Delimiter Matching and Text Selection
Code Block Folding
Multicursors
Reusable Code Snippets
Word Completion
Minimap Mode
Sticky Scroll
Whitespace Rendering and Breadcrumbs
Markdown Preview
Evolved Code Editing
Working with IntelliSense
Parameter Hints
Inline Documentation with Tooltips
Go to Definition and Peek Definition
Go to Implementation and Peek Implementations
Finding References
Renaming Symbols and Identifiers
Live Code Analysis
Hints About IntelliCode
Summary
Chapter 4:​Working with Files and Folders
Visual Studio Code and Project Systems
Working with Individual Files
Creating Files
File Encoding, Line Terminators, and Line Browsing
Working with Folders and Projects
Opening a Folder
Opening .​NET Solutions
Opening JavaScript and TypeScript Projects
Opening Loose Folders
Working with Workspaces
Creating Workspaces
Opening Existing Workspaces
Workspace Structure
Security:​Workspace Trust
Summary
Chapter 5:​Customizing Visual Studio Code
Customizations and Extensions Explained
Customizing Visual Studio Code
Theme Selection
Customizing the Environment
Customizing Keyboard Shortcuts
Creating Reusable Profiles
Summary
Chapter 6:​Installing and Managing Extensions
Installing Extensions
Extension Recommendations
Useful Extensions
Managing Extensions
Configuring Extensions
Writing Your First Extension
Setting Up the Environment
Creating an Extension
Developing the Extension
Running the Extension
Packaging Extensions
Extension Development Summary
Summary
Chapter 7:​Source Control with Git
Source Control in Visual Studio Code
Downloading Other Source Control Providers
Managing Repositories
Initializing a Local Git Repository
Creating a Remote Repository
Handling File Changes
Staging Changes
Managing Commits
Working with the Git Command-Line Interface
Creating and Managing Branches
Switching to a Different Branch
Merging from a Branch
Hints About Rebasing Branches
Deleting Branches
Adding Power to the Git Tooling with Extensions
Git History
GitLens
GitHub Pull Requests and Issues
Working with Azure DevOps
Creating a Team Project
Connecting Visual Studio Code to a Remote Repository
Summary
Chapter 8:​Automating Tasks
Understanding Tasks
Tasks Types
Running and Managing Tasks
The Default Build Task
Auto-Detected Tasks
Configuring Tasks
Running Files with a Default Program
Summary
Chapter 9:​Building and Debugging Applications
Creating Applications
The Status of Microsoft .​NET
Creating .​NET Projects
Creating Projects on Other Platforms
Debugging Your Code
Configuring the Debugger
Managing Breakpoints
Debugging an Application
Configuring Debug Options
Summary
Chapter 10:​Building Applications with Python
Chapter Prerequisites
Creating Python Applications
Running Python Code
Code Editing Features for Python
Enhanced Word Completion with IntelliSense
Understanding Function Parameters with Parameter Hints
Quickly Retrieving Type Definitions
Finding References
Renaming Symbols
Finding Code Issues with Linters
Advanced Code Editing with Pylance
Managing Pylance Settings
Running Python Scripts
Summary
Chapter 11:​Deploying Applications to Azure
Introducing Azure Extensions
Deploying Web Applications
Installing Extensions
Signing In to Azure Subscriptions
Publishing Web Applications
Creating and Deploying Azure Functions
Configuring Visual Studio Code
Creating Azure Functions
Deploying Azure Functions
Deploying Docker Images
Docker Prerequisites
Creating the Application Image
Uploading the Application Image to a Container Registry
Deploying the Docker Image to Azure
Summary
Chapter 12:​Consuming AI Services
Introducing Azure for AI
General Considerations
Introducing Computer Vision
Setting Up Computer Vision Services
Retrieving the Service Keys
Consuming AI Services with .​NET
Setting Up Variables and Constants
Creating Authenticated Service Clients
Executing Image Analysis
Running the Application
Consuming AI Services with JavaScript
Setting Up Variables and Constants
Creating Authenticated Service Clients
Executing Image Analysis
Running the Application
Consuming AI Services with Python
Setting Up Variables and Constants
Creating Authenticated Service Clients
Executing Image Analysis
Running the Application
Summary
Index
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#.

OceanofPDF.com
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
A. Del Sole, Visual Studio Code Distilled
https://doi.org/10.1007/978-1-4842-9484-0_1

1. Introducing Visual Studio Code


Alessandro Del Sole1
(1) Cremona, Italy

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.

Visual Studio Code, a Cross-Platform


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 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 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 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.
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/portab
le) 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.

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 rightclick 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 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

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

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.

Figure 1-4 Visual Studio Code running on Ubuntu

Note If you are a Windows user and want to try Visual Studio Code on
a Linux distribution, you can create a virtual machine with the Hyper-V
tool. For example, you 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.

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

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.

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

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.

Summary
Visual Studio Code is not a simple code editor, but a fully featured
development environment optimized for web, mobile, and cloud
development. In this chapter, you saw how to install Visual Studio Code on
Windows, macOS, and Linux distributions, learning how to select the
appropriate installers and fine-tune the setup process. You also saw how to
configure localization and updates. Next, you looked at the Insiders builds,
which offer previews of upcoming, unreleased features. Finally, you saw
Visual Studio Code running in the browser as a web app, with the same
features as the desktop version.
Now that your environment is ready for use, it is time to start
discovering the amazing features offered by Visual Studio Code. The next
chapter walks through the environment, then in Chapter 3, you learn about
all the amazing code-editing features that make Visual Studio Code a rich,
powerful crossplatform editor.
OceanofPDF.com
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2023
A. Del Sole, Visual Studio Code Distilled
https://doi.org/10.1007/978-1-4842-9484-0_2

2. Getting to Know the Environment


Alessandro Del Sole1
(1) Cremona, Italy

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

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

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.
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 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
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.
Figure 2-6 The Outline view on a TypeScript file
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, 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.

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.
Other documents randomly have
different content
settling the plough on his neck,[31] made him work as wont; but the
Bull began to shirk his ploughing, according to the advice of the Ass,
and the ploughman drubbed him till he broke the yoke and made
off; but the man caught him up and leathered him till he despaired
of his life. Not the less, however, would he do nothing but stand still
and drop down till the evening. Then the herd led him home and
stabled him in his stall: but he drew back from his manger and
neither stamped nor ramped nor butted nor bellowed as he was
wont to do; whereat the man wondered. He brought him the beans
and husks, but he sniffed at them and left them and lay down as far
from them as he could and passed the whole night fasting. The
peasant came next morning; and, seeing the manger full of beans,
the crushed-straw untasted and the ox lying on his back in sorriest
plight, with legs outstretched and swollen belly, he was concerned
for him, and said to himself, "By Allah, he hath assuredly sickened
and this is the cause why he would not plough yesterday." Then he
went to the merchant and reported, "O my master, the Bull is ailing;
he refused his fodder last night; nay more, he hath not tasted a
scrap of it this morning." Now the merchant-farmer understood what
all this meant, because he had overheard the talk between the Bull
and the Ass, so quoth he, "Take that rascal donkey, and set the yoke
on his neck, and bind him to the plough and make him do Bull's
work." Thereupon the ploughman took the Ass, and worked him
through the livelong day at the Bull's task; and, when he failed for
weakness, he made him eat stick till his ribs were sore and his sides
were sunken and his neck was flayed by the yoke; and when he
came home in the evening he could hardly drag his limbs along,
either forehand or hind-legs. But as for the Bull, he had passed the
day lying at full length and had eaten his fodder with an excellent
appetite, and he ceased not calling down blessings on the Ass for his
good advice, unknowing what had come to him on his account. So
when night set in and the Ass returned to the byre the Bull rose up
before him in honour, and said, "May good tidings gladden thy heart,
O Father Wakener! through thee I have rested all this day and I
have eaten my meat in peace and quiet." But the Ass returned no
reply, for wrath and heart-burning and fatigue and the beating he
had gotten; and he repented with the most grievous of repentance;
and quoth he to himself: "This cometh of my folly in giving good
counsel; as the saw saith, I was in joy and gladness, nought save
my officiousness brought me this sadness. But I will bear in mind my
innate worth and the nobility of my nature; for what saith the poet?
Shall the beautiful hue of the Basil[32] fail ✿ Tho' the beetle's foot o'er the Basil
crawl?
And though spider and fly be its denizens ✿ Shall disgrace attach to the royal
hall?
The cowrie,[33] I ken, shall have currency ✿ But the pearl's clear drop, shall its
value fall?

And now I must take thought and put a trick upon him and return
him to his place, else I die." Then he went aweary to his manger,
while the Bull thanked him and blessed him. And even so, O my
daughter, said the Wazir, thou wilt die for lack of wits; therefore sit
thee still and say naught and expose not thy life to such stress; for,
by Allah, I offer thee the best advice, which cometh of my affection
and kindly solicitude for thee. "O my father," she answered, "needs
must I go up to this King and be married to him." Quoth he, "Do not
this deed;" and quoth she, "Of a truth I will:" whereat he rejoined,
"If thou be not silent and bide still, I will do with thee even what the
merchant did with his wife." "And what did he?" asked she. Know
then, answered the Wazir, that after the return of the Ass the
merchant came out on the terrace-roof with his wife and family, for
it was a moonlit night and the moon at its full. Now the terrace
overlooked the cowhouse and presently, as he sat there with his
children playing about him, the trader heard the Ass say to the Bull,
"Tell me, O father Broad o' Brow, what thou purposest to do to-
morrow?" The Bull answered, "What but continue to follow thy
counsel, O Aliboron? Indeed it was as good as good could be and it
hath given me rest and repose; nor will I now depart from it one
tittle: so, when they bring me my meat, I will refuse it and blow out
my belly and counterfeit crank." The Ass shook his head and said,
"Beware of so doing, O Father of a Bull!" The Bull asked, "Why," and
the Ass answered, "Know that I am about to give thee the best of
counsel, for verily I heard our owner say to the herd, If the Bull rise
not from his place to do his work this morning and if he retire from
his fodder this day, make him over to the butcher that he may
slaughter him and give his flesh to the poor, and fashion a bit of
leather[34] from his hide. Now I fear for thee on account of this. So
take my advice ere a calamity befal thee; and when they bring thee
thy fodder eat it and rise up and bellow and paw the ground, or our
master will assuredly slay thee: and peace be with thee!" Thereupon
the Bull arose and lowed aloud and thanked the Ass, and said, "To-
morrow I will readily go forth with them;" and he at once ate up all
his meat and even licked the manger. (All this took place and the
owner was listening to their talk.) Next morning the trader and his
wife went to the Bull's crib and sat down, and the driver came and
led forth the Bull who, seeing his owner, whisked his tail and brake
wind, and frisked about so lustily that the merchant laughed a loud
laugh and kept laughing till he fell on his back. His wife asked him,
"Whereat laughest thou with such loud laughter as this?"; and he
answered her, "I laughed at a secret something which I have heard
and seen but cannot say lest I die my death." She returned,
"Perforce thou must discover it to me, and disclose the cause of thy
laughing even if thou come by thy death!" But he rejoined, "I cannot
reveal what beasts and birds say in their lingo for fear I die. Then
quoth she, "By Allah, thou liest! this is a mere pretext: thou laughest
at none save me, and now thou wouldest hide somewhat from me.
But by the Lord of the Heavens! an thou disclose not the cause I will
no longer cohabit with thee: I will leave thee at once." And she sat
down and cried. Whereupon quoth the merchant, "Woe betide thee!
what means thy weeping? Fear Allah and leave these words and
query me no more questions." "Needs must thou tell me the cause
of that laugh," said she, and he replied, "Thou wottest that when I
prayed Allah to vouchsafe me understanding of the tongues of
beasts and birds, I made a vow never to disclose the secret to any
Under pain of dying on the spot." "No matter," cried she, "tell me
what secret passed between the Bull and the Ass and die this very
hour an thou be so minded;" and she ceased not to importune him
till he was worn out and clean distraught. So at last he said,
"Summon thy father and thy mother and our kith and kin and sundry
of our neighbours," which she did; and he sent for the Kazi[35] and
his assessors, intending to make his will and reveal to her his secret
and die the death; for he loved her with love exceeding because she
was his cousin, the daughter of his father's brother, and the mother
of his children, and he had lived with her a life of an hundred and
twenty years. Then, having assembled all the family and the folk of
his neighbourhood, he said to them, "By me there hangeth a strange
story, and 'tis such that if I discover the secret to any, I am a dead
man." Therefore quoth every one of those present to the woman,
"Allah upon thee, leave this sinful obstinacy and recognise the right
of this matter, lest haply thy husband and the father of thy children
die." But she rejoined, "I will not turn from it till he tell me, even
though he come by his death." So they ceased to urge her; and the
trader rose from amongst them and repaired to an outhouse to
perform the Wuzu-ablution,[36] and he purposed thereafter to return
and to tell them his secret and to die. Now, daughter Shahrazad,
that merchant had in his out-houses some fifty hens under one cock,
and whilst making ready to farewell his folk he heard one of his
many farm-dogs thus address in his own tongue the Cock, who was
flapping his wings and crowing lustily and jumping from one hen's
back to another and treading all in turn, saying "O Chanticleer! how
mean is thy wit and how shameless is thy conduct! Be he
disappointed who brought thee up?[37] Art thou not ashamed of thy
doings on such a day as this?" "And what," asked the Rooster, "hath
occurred this day?," when the Dog answered, "Dost thou not know
that our master is this day making ready for his death? His wife is
resolved that he shall disclose the secret taught to him by Allah, and
the moment he so doeth he shall surely die. We dogs are all a-
mourning; but thou clappest thy wings and clarionest thy loudest
and treadest hen after hen. Is this an hour for pastime and
pleasuring? Art thou not ashamed of thyself?"[38] "Then by Allah,"
quoth the Cock, "is our master a lack-wit and a man scanty of sense:
if he cannot manage matters with a single wife, his life is not worth
prolonging. Now I have some fifty Dame Partlets; and I please this
and provoke that and starve one and stuff another; and through my
good governance they are all well under my control. This our master
pretendeth to wit and wisdom, and he hath but one wife, and yet
knoweth not how to manage her." Asked the Dog, "What then, O
Cock, should the master do to win clear of his strait?" "He should
arise forthright," answered the Cock, "and take some twigs from yon
mulberry-tree and give her a regular back-basting and rib-roasting
till she cry:—I repent, O my lord! I will never ask thee a question as
long as I live! Then let him beat her once more and soundly, and
when he shall have done this he shall sleep free from care and enjoy
life. But this master of ours owns neither sense nor judgment."
"Now, daughter Shahrazad," continued the Wazir, "I will do to thee
as did that husband to that wife." Said Shahrazad, "And what did he
do?" He replied, "When the merchant heard the wise words spoken
by his Cock to his Dog, he arose in haste and sought his wife's
chamber, after cutting for her some mulberry-twigs and hiding them
there; and then he called to her, "Come into the closet that I may
tell thee the secret while no one seeth me and then die." She
entered with him and he locked the door and came down upon her
with so sound a beating of back and shoulders, ribs, arms and legs,
saying the while, "Wilt thou ever be asking questions about what
concerneth thee not?" that she was well nigh senseless. Presently
she cried out, "I am of the repentant! By Allah, I will ask thee no
more questions, and indeed I repent sincerely and wholesomely."
Then she kissed his hand and feet and he led her out of the room
submissive as a wife should be. Her parents and all the company
rejoiced and sadness and mourning were changed into joy and
gladness. Thus the merchant learnt family discipline from his Cock
and he and his wife lived together the happiest of lives until death.
And thou also, O my daughter! continued the Wazir, "Unless thou
turn from this matter I will do by thee what that trader did to his
wife." But she answered him with much decision, "I will never desist,
O my father, nor shall this tale change my purpose. Leave such talk
and tattle. I will not listen to thy words and, if thou deny me, I will
marry myself to him despite the nose of thee. And first I will go up
to the King myself and alone and I will say to him:—I prayed my
father to wive me with thee, but he refused, being resolved to
disappoint his lord, grudging the like of me to the like of thee." Her
father asked, "Must this needs be?" and she answered, "Even so."
Hereupon the Wazir being weary of lamenting and contending,
persuading and dissuading her, all to no purpose, went up to King
Shahryar and, after blessing him and kissing the ground before him,
told him all about his dispute with his daughter from first to last and
how he designed to bring her to him that night. The King wondered
with exceeding wonder; for he had made an especial exception of
the Wazir's daughter, and said to him, "O most faithful of
Counsellors, how is this? Thou wottest that I have sworn by the
Raiser of the Heavens that after I have gone into her this night I
shall say to thee on the morrow's morning:—Take her and slay her!
and, if thou slay her not, I will slay thee in her stead without fail."
"Allah guide thee to glory and lengthen thy life, O King of the age,"
answered the Wazir, "it is she that hath so determined: all this have
I told her and more; but she will not hearken to me and she
persisteth in passing this coming night with the King's Majesty." So
Shahryar rejoiced greatly and said, "'Tis well; go get her ready and
this night bring her to me." The Wazir returned to his daughter and
reported to her the command saying, "Allah make not thy father
desolate by thy loss!" But Shahrazad rejoiced with exceeding joy and
gat ready all she required and said to her younger sister, Dunyazad,
"Note well what directions I entrust to thee! When I have gone into
the King I will send for thee and when thou comest to me and seest
that he hath had his carnal will of me, do thou say to me:—O my
sister, an thou be not sleepy, relate to me some new story,
delectable and delightsome, the better to speed our waking hours;"
and I will tell thee a tale which shall be our deliverance, if so Allah
please, and which shall turn the King from his blood-thirsty custom."
Dunyazad answered "With love and gladness." So when it was night
their father the Wazir carried Shahrazad to the King who was
gladdened at the sight and asked, "Hast thou brought me my need?"
and he answered, "I have." But when the King took her to his bed
and fell to toying with her and wished to go in to her she wept;
which made him ask, "What aileth thee?" She replied, "O King of the
age, I have a younger sister and lief would I take leave of her this
night before I see the dawn." So he sent at once for Dunyazad and
she came and kissed the ground between his hands, when he
permitted her to take her seat near the foot of the couch. Then the
King arose and did away with his bride's maidenhead and the three
fell asleep. But when it was midnight Shahrazad awoke and signalled
to her sister Dunyazad who sat up and said, "Allah upon thee, O my
sister, recite to us some new story, delightsome and delectable,
wherewith to while away the waking hours of our latter night."[39]
"With joy and goodly gree," answered Shahrazad, "if this pious and
auspicious King permit me." "Tell on," quoth the King who chanced
to be sleepless and restless and therefore was pleased with the
prospect of hearing her story. So Shahrazad rejoiced; and thus, on
the first night of the Thousand Nights and a Night, she began with
the

1. Ailaho A'alam, a deprecatory formula, used because the writer


is going to indulge in a series of what may possibly be
untruths.

2. The "Sons of Sásán" are the famous Sassanides whose dynasty


ended with the Arabian Conquest (A.D. 641). "Island" (Jazírah)
in Arabic also means "Peninsula," and causes much confusion
in geographical matters.

3. Shahryár not Shahriyar (Persian)="City-friend." The Bulak


edition corrupts it to Shahrbáz (City-hawk), and the Breslau to
Shahrbán or "Defender of the City," like Marz-ban=Warden of
the Marshes. Shah Zamán (Persian)="King of the Age:" Galland
prefers Shah Zenan, or "King of women," and the Bul. edit.
changes it to Shah Rummán, "Pomegranate King." Al-Ajam
denotes all regions not Arab (Gentiles opposed to Jews,
Mlechchhas to Hindus, Tajiks to Turks, etc., etc.), and
especially Persia; Ajami (a man of Ajam) being an equivalent of
the Gr. Βάρβαρος. See Vol. ii., p. 1.
4. Galland writes "Vizier," a wretched frenchification of a mincing
Turkish mispronunciation; Torrens, "Wuzeer" (Anglo-Indian and
Gilchristian); Lane, "Wezeer" (Egyptian or rather Cairene);
Payne, "Vizier," according to his system; Burckhardt (Proverbs),
"Vizír;" and Mr. Keith-Falconer, "Vizir." The root is popularly
supposed to be "wizr" (burden) and the meaning "Minister;"
Wazír al-Wuzará being "Premier." In the Koran (chapt. xx., 30)
Moses says, "Give me a Wazir of my family, Harun (Aaron) my
brother." Sale, followed by the excellent version of the Rev. J.
M. Rodwell, translates a "Counsellor," and explains by "One
who has the chief administration of affairs under a prince." But
both learned Koranists learnt their Orientalism in London, and,
like such students generally, fail only upon the easiest points,
familiar to all old dwellers in the East.

5. This three-days term (rest-day, drest-day and departure day)


seems to be an instinct-made rule in hospitality. Among
Moslems it is a Sunnat or practice of the Prophet.

6. i.e., I am sick at heart.

7. Debauched women prefer negroes on account of the size of


their parts. I measured one man in Somali-land who, when
quiescent, numbered nearly six inches. This is a characteristic
of the negro race and of African animals: e.g. the horse;
whereas the pure Arab, man and beast, is below the average
of Europe; one of the best proofs by the by, that the Egyptian
is not an Asiatic, but a negro partially whitewashed. Moreover,
these imposing parts do not increase proportionally during
erection; consequently, the "deed of kind" takes a much longer
time and adds greatly to the woman's enjoyment. In my time
no honest Hindi Moslem would take his womenfolk to Zanzibar
on account of the huge attractions and enormous temptations
there and thereby offered to them. Upon the subject of
Imsák=retention of semen and "prolongation of pleasure," I
shall find it necessary to say more.
8. The very same words were lately spoken in England proving
the eternal truth of The Nights which the ignorant call
"downright lies."

9. The Arab's Tue la!

10. Arab. "Sayd wa kanas": the former usually applied to fishing;


hence Sayda (Sidon)=fish-town. But noble Arabs (except the
Caliph Al-Amin) do not fish; so here it means simply "sport,"
chasing, coursing, birding (oiseler), and so forth.

11. In the Mac. Edit, the negro is called "Mas'úd"; here he utters a
kind of war-cry and plays upon the name, Sa'ád, Sa'íd, Sa'úd,
and Mas'ud, all being derived from one root,
"Sa'ad"=auspiciousness, prosperity.

12. The Arab singular (whence the French "génie"); fem. Jinniyah;
the Div and Rakshah of old Guebre-land and the "Rakshasa,"
or "Yaksha," of Hinduism. It would be interesting to trace the
evident connection, by no means "accidental," of "Jinn" with
the "Genius" who came to the Romans through the Asiatic
Etruscans, and whose name I cannot derive from "gignomai"
or "genitus." He was unknown to the Greeks, who had the
Daimon (δαίμον), a family which separated, like the Jinn and
the Genius, into two categories, the good (Agatho-dæmons)
and the bad (Kako-dæmons). We know nothing concerning the
status of the Jinn amongst the pre-Moslemitic or pagan Arabs:
the Moslems made him a supernatural anthropoid being,
created of subtile fire (Koran, chapts. xv. 27; lv. 14), not of
earth like man, propagating his kind, ruled by mighty kings,
the last being Ján bin Ján, missionarised by Prophets and
subject to death and Judgment. From the same root are
"Junún"=madness (i.e., possession or obsession by the Jinn)
and "Majnún"=a madman. According to R. Jeremiah bin Eliazar
in Psalm xli. 5, Adam was excommunicated for one hundred
and thirty years, during which he begat children in his own
image (Gen. v. 3) and these were Mazikeen or Shedeem—
Jinns. Further details anent the Jinn will presently occur.

13. Arab "Amsár" (cities): in Bul. Edit. "Amtár" (rains), as in Mac.


Edit. So Mr. Payne (I., 5) translates:—
And when she flashes forth the lightning of her glance, She maketh eyes
to rain, like showers, with many a tear.

I would render it, "She makes whole cities shed tears;" and
prefer it for a reason which will generally influence me—its
superior exaggeration and impossibility.

14. Not "A-frit," pronounced Aye-frit, as our poets have it. This
variety of the Jinn, who, as will be shown, are divided into two
races like mankind, is generally, but not always, a malignant
being, hostile and injurious to mankind (Koran xxvii. 39).

15. i.e., "I conjure thee by Allah;" the formula is technically called
"Inshád."

16. This introducing the name of Allah into an indecent tale is


essentially Egyptian and Cairene. But see Boccacio ii. 6; and
vii. 9.

17. So in the Mac. Edit.; in others "ninety." I prefer the greater


number as exaggeration is a part of the humour. In the Hindu
"Kathá Sárit Ságara" (Sea of the Streams of Story), the rings
are one hundred and the catastrophe is more moral; the good
youth Yashodhara rejects the wicked one's advances; she
awakes the water-sprite, who is about to slay him, but the
rings are brought as testimony and the improper young
person's nose is duly cut off. (Chapt. lxiii.; p. 80, of the
excellent translation by Prof. C. H. Tawney: for the Bibliotheca
Indica: Calcutta, 1881.) The Kathá, etc., by Somadeva (century
xi), is a poetical version of the prose compendium, the "Vrihat
Kathá" (Great Story) by Gunadhya (cent. vi).
18. The Joseph of the Koran, very different from him of Genesis.
We shall meet him often enough in The Nights.

19. "Iblis," vulgarly written "Eblis," from a root meaning The


Despairer, with a suspicious likeness to Diabolos; possibly from
"Balas," a profligate. Some translate it The Calumniator, as
Satan is the Hater. Iblis (who appears in the Arab. version of
the N. Testament) succeeded another revolting angel Al-Haris;
and his story of pride, refusing to worship Adam, is told four
times in the Koran from the Talmud (Sanhedrim 29). He caused
Adam and Eve to lose Paradise (ii. 34); he still betrays mankind
(xxv. 31), and at the end of time he, with the other devils, will
be "gathered together on their knees round Hell" (xix. 69). He
has evidently had the worst of the game and we wonder, with
Origen, Tillotson, Burns and many others, that he does not
throw up the cards.

20. A similar tale is still told at Akká (St. John d'Acre) concerning
the terrible "butcher"—Jazzár (Djezzar) Pasha. One can·hardly
pity women who are fools enough to run such risks. According
to Frizzi, Niccolò, Marquis of Este, after beheading Parisina,
ordered all the faithless wives of Ferrara to be treated in like
manner.

21. "Shahrázád (Persian)=City-freer; in the older version


Scheherazade (probably both from Shirzád=lion-born).
"Dunyázád=World-freer. The Bres. Edit. corrupts the former to
Sháhrzád or Sháhrazád; and the Mac. and Calc. to Shahrzád or
Shehrzád. I have ventured to restore the name as it should be.
Galland for the second prefers Dinarzade (?) and Richardson
Dinazade (Dinázád=Religion-freer): here I have followed Lane
and Payne; though in "First Footsteps" I was misled by
Galland. See Vol. ii. p. 1.

22. Probably she proposed to "Judith" the King. These learned and
clever young ladies are very dangerous in the East.
23. In Egypt, etc., the bull takes the place of the Western ox. The
Arab. word is "Taur" (Thaur, Saur); in old Persian "Tora" and
Lat. "Taurus," a venerable remnant of the days before the
"Semitic" and "Aryan" families of speech had split into two
distinct growths. "Taur" ends in the Saxon "Steor" and the
English "Steer."

24. Arab. "Abú Yakzán"=the Wakener; because the ass brays at


dawn.

25. Arab. "Tibn"; straw crushed under the sledge: the hay of
Egypt, Arabia, Syria, etc. The old country custom is to pull up
the corn by handfuls from the roots, leaving the land perfectly
bare: hence the "plucking up" of Hebrew Holy Writ. The object
is to preserve every atom of "Tibn."

26. Arab. "Yá Aftah": Al-Aftah is an epithet of the bull, also of the
chameleon.

27. Arab. "Balid," a favourite Egyptianism often pleasantly


confounded with "Wali" (a Santon); hence the latter comes to
mean "an innocent," a "ninny."

28. From the Calc. Edit., Vol. I., p. 29.

29. Arab. "Abu Yakzán" is hardly equivalent with "Père l'Eveillé."

30. In Arab. the wa (‫ )َو‬is the sign of parenthesis.

31. In the nearer East the light little plough is carried a-field by the
bull or ass.

32. Ocymum basilicum, the "royal herb," so much prized all over
the East, especially in India, where, under the name of "Tulsi,"
it is a shrub sacred to the merry god Krishna. I found the
verses in a MS. copy of the Nights.
33. Arab. "Sadaf," the Kauri, or cowrie, brought from the Maldive
and Lakdive Archipelago. The Kámús describes this "Wada'" or
Concha Veneris as "a white shell [whence to "shell out"] which
is taken out of the sea, the fissure of which is white like that of
the date-stone. It is hung about the neck to avert the evil eye."
The pearl in Arab. is "Murwarid," hence evidently "Margarita"
and Margaris (woman's name).

34. Arab. "Kat'a" (bit of leather): some read "Nat'a," a leather used
by way of table-cloth, and forming a bag for victuals; but it is
never made of bull's hide.

35. The Older "Cadi," a judge in religious matters. The Shuhúd, or


Assessors, are officers of the Mahkamah or Kazi's Court.

36. Of which more in a future page. He thus purified himself


ceremonially before death.

37. This is Christian rather than Moslem: a favourite Maltese curse


is "Yahrak Kiddísak man rabba-k!"=burn the Saint who brought
thee up!

38. A popular Egyptian phrase: the dog and the cock speak like
Fellahs.

39. i.e. between the last sleep and dawn when they would rise to
wash and pray.
TALE OF THE TRADER AND THE JINNI.

It is related, O auspicious King, that there was a merchant of the


merchants who had much wealth, and business in various cities.
Now on a day he mounted horse and went forth to recover monies
in certain towns, and the heat sore oppressed him; so he sat
beneath a tree and, putting his hand into his saddle-bags, took
thence some broken bread and dry dates and began to break his
fast. When he had ended eating the dates he threw away the
stones with force and lo! an Ifrit appeared, huge of stature and
brandishing a drawn sword, wherewith he approached the
merchant and said, "Stand up that I may slay thee, even as thou
slewest my son!" Asked the merchant, "How have I slain thy son?"
and he answered, "When thou atest dates and threwest away the
stones they struck my son full in the breast as he was walking by,
so that he died forthwith."[40] Quoth the merchant, "Verily from
Allah we proceeded and unto Allah are we returning. There is no
Majesty, and there is no Might save in Allah, the Glorious, the
Great! If I slew thy son, I slew him by chance medley. I pray thee
now pardon me." Rejoined the Jinni, "There is no help but I must
slay thee." Then he seized him and dragged him along and, casting
him to the earth, raised the sword to strike him; whereupon the
merchant wept, and said, "I commit my case to Allah," and began
repeating these couplets:—
Containeth Time a twain of days, this of blessing that of bane ✿ And holdeth Life
a twain of halves, this of pleasure that of pain.
See'st not when blows the hurricane, sweeping stark and striking strong ✿ None
save the forest giant feels the suffering of the strain?
How many trees earth nourisheth of the dry and of the green ✿ Yet none but
those which bear the fruits for cast of stone complain.
See'st not how corpses rise and float on the surface of the tide ✿ While pearls o'
price lie hidden in the deepest of the main!
In Heaven are unnumberèd the many of the stars ✿ Yet ne'er a star but Sun and
Moon by eclipse is overta'en.
Well judgest thou the days that saw thy faring sound and well ✿ And countedst
not the pangs and pain whereof Fate is ever fain.
The nights have kept thee safe and the safety brought thee pride ✿ But bliss and
blessings of the night are 'genderers of bane!

When the merchant ceased repeating his verses the Jinni said to
him, "Cut thy words short, by Allah! needs must I slay thee." But the
merchant spake him thus, "Know, O thou Ifrit, that I have debts due
to me and much wealth and children and a wife and many pledges
in hand; so permit me to go home and discharge to every claimant
his claim; and I will come back to thee at the head of the new year.
Allah be my testimony and surety that I will return to thee; and then
thou mayest do with me as thou wilt and Allah is witness to what I
say." The Jinni took sure promise of him and let him go; so he
returned to his own city and transacted his business and rendered to
all men their dues and after informing his wife and children of what
had betided him, he appointed a guardian and dwelt with them for a
full year. Then he arose, and made the Wuzu-ablution to purify
himself before death and took his shroud under his arm and bade
farewell to his people, his neighbours and all his kith and kin, and
went forth despite his own nose.[41] They then began weeping and
wailing and beating their breasts over him; but he travelled until he
arrived at the same garden, and the day of his arrival was the head
of the New Year. As he sat weeping over what had befallen him,
behold, a Shaykh,[42] a very ancient man, drew near leading a
chained gazelle; and he saluted that merchant and wishing him long
life said, "What is the cause of thy sitting in this place and thou
alone and this be a resort of evil spirits?" The merchant related to
him what had come to pass with the Ifrit, and the old man, the
owner of the gazelle, wondered and said, "By Allah, O brother, thy
faith is none other than exceeding faith and thy story right strange;
were it graven with gravers on the eye-corners, it were a warner to
whoso would be warned." Then seating himself near the merchant
he said, "By Allah, O my brother, I will not leave thee until I see
what may come to pass with thee and this Ifrit." And presently as he
sat and the two were at talk the merchant began to feel fear and
terror and exceeding grief and sorrow beyond relief and ever-
growing care and extreme despair. And the owner of the gazelle was
hard by his side; when behold, a second Shaykh approached them,
and with him were two dogs both of greyhound breed and both
black. The second old man after saluting them with the salam, also
asked them of their tidings and said "What causeth you to sit in this
place, a dwelling of the Jánn?"[43] So they told him the tale from
beginning to end, and their stay there had not lasted long before
there came up a third Shaykh, and with him a she-mule of bright
bay coat; and he saluted them and asked them why they were
seated in that place. So they told him the story from first to last: and
of no avail, O my master, is a twice-told tale! There he sat down with
them, and lo! a dust-cloud advanced and a mighty sand-devil
appeared amidmost of the waste. Presently the cloud opened and
behold, within it was that Jinni hending in hand a drawn sword,
while his eyes were shooting fire-sparks of rage. He came up to
them and, haling away the merchant from among them, cried to
him, "Arise that I may slay thee, as thou slewest my son, the life-
stuff of my liver."[44] The merchant wailed and wept, and the three
old men began sighing and crying and weeping and wailing with
their companion. Presently the first old man (the owner of the
gazelle) came out from among them and kissed the hand of the Ifrit
and said, "O Jinni, thou Crown of the Kings of the Jann! were I to
tell thee the story of me and this gazelle and thou shouldst consider
it wondrous wouldst thou give me a third part of this merchant's
blood?" Then quoth the Jinni "Even so, O Shaykh! if thou tell me this
tale, and I hold it a marvellous, then will I give thee a third of his
blood." Thereupon the old man began to tell
THE FIRST SHAYKH'S STORY.
Know O Jinni! that this gazelle is the daughter of my paternal uncle,
my own flesh and blood, and I married her when she was a young
maid, and I lived with her well-nigh thirty years, yet was I not
blessed with issue by her. So I took me a concubine,[45] who brought
to me the boon of a male child fair as the full moon, with eyes of
lovely shine and eyebrows which formed one line, and limbs of
perfect design. Little by little he grew in stature and waxed tall; and
when he was a lad fifteen years old, it became needful I should
journey to certain cities and I travelled with great store of goods.
But the daughter of my uncle (this gazelle) had learned gramarye
and egromancy and clerkly craft[46] from her childhood; so she
bewitched that son of mine to a calf, and my handmaid (his mother)
to a heifer, and made them over to the herdsman's care. Now when
I returned after a long time from my journey and asked for my son
and his mother, she answered me, saying "Thy slave-girl is dead,
and thy son hath fled and I know not whither he is sped." So I
remained for a whole year with grieving heart, and streaming eyes
until the time came for the Great Festival of Allah.[47] Then sent I to
my herdsman bidding him choose for me a fat heifer; and he
brought me one which was the damsel, my handmaid, whom this
gazelle had ensorcelled. I tucked up my sleeves and skirt and, taking
a knife, proceeded to cut her throat, but she lowed aloud and wept
bitter tears. Thereat I marvelled and pity seized me and I held my
hand, saying to the herd, "Bring me other than this." Then cried my
cousin, "Slay her, for I have not a fatter nor a fairer!" Once more I
went forward to sacrifice her, but she again lowed aloud, upon which
in ruth I refrained and commanded the herdsmen to slay her and
flay her. He killed her and skinned her but found in her neither fat
nor flesh, only hide and bone; and I repented when penitence
availed me naught. I gave her to the herdsman and said to him,
"Fetch me a fat calf;" so he brought my son ensorcelled. When the
calf saw me, he brake his tether and ran to me, and fawned upon
me and wailed and shed tears; so that I took pity on him and said to
the herdsman, "Bring me a heifer and let this calf go!" Thereupon
my cousin (this gazelle) called aloud at me, saying, "Needs must
thou kill this calf; this is a holy day and a blessed, whereon naught is
slain save what be perfect-pure; and we have not amongst our
calves any fatter or fairer than this!" Quoth I, "Look thou upon the
condition of the heifer which I slaughtered at thy bidding and how
we turn from her in disappointment and she profited us on no wise;
and I repent with an exceeding repentance of having killed her: so
this time I will not obey thy bidding for the sacrifice of this calf."
Quoth she, "By Allah the Most Great, the Compassionating, the
Compassionate! there is no help for it; thou must kill him on this
holy day, and if thou kill him not to me thou art no man and I to
thee am no wife." Now when I heard those hard words, not knowing
her object I went up to the calf, knife in hand——And Shahrazad
perceived the dawn of day and ceased to say her permitted say.[48]
Then quoth her sister to her, "How fair is thy tale, and how grateful,
and how sweet and how tasteful!" And Shahrazad answered her,
"What is this to that I could tell thee on the coming night, were I to
live and the King would spare me?" Then said the King in himself,
"By Allah, I will not slay her, until I shall have heard the rest of her
tale." So they slept the rest of that night in mutual embrace till day
fully brake. Then the King went forth to his audience-hall[49] and the
Wazir went up with his daughter's shroud under his arm. The King
issued his orders, and promoted this and deposed that, until the end
of the day; and he told the Wazir no whit of what had happened.
But the Minister wondered thereat with exceeding wonder; and
when the Court broke up King Shahryar entered his palace.

Now when it was the Second Night,

said Dunyazad to her sister Shahrazad, "O my sister, finish for us


that story of the Merchant and the Jinni;" and she answered, "With
joy and goodly gree, if the King permit me." Then quoth the King,
"Tell thy tale;" and Shahrazad began in these words: It hath reached
me, O auspicious King and Heaven-directed Ruler! that when the
merchant purposed the sacrifice of the calf but saw it weeping, his
heart relented and he said to the herdsman, "Keep the calf among
my cattle." All this the old Shaykh told the Jinni who marvelled much
at these strange words. Then the owner of the gazelle continued:—O
Lord of the Kings of the Jann, this much took place and my uncle's
daughter, this gazelle, looked on and saw it, and said, "Butcher me
this calf, for surely it is a fat one;" but I bade the herdsman take it
away and he took it and turned his face homewards. On the next
day as I was sitting in my own house, lo! the herdsman came and,
standing before me said, "O my master, I will tell thee a thing which
shall gladden thy soul, and shall gain me the gift of good tidings."[50]
I answered, "Even so." Then said he, "O merchant, I have a
daughter, and she learned magic in her childhood from an old
woman who lived with us. Yesterday when thou gavest me the calf, I
went into the house to her, and she looked upon it and veiled her
face; then she wept and laughed alternately and at last she said:—O
my father, hath mine honour become so cheap to thee that thou
bringest in to me strange men? I asked her:—Where be these
strange men and why wast thou laughing, and crying?; and she
answered, Of a truth this calf which is with thee is the son of our
master, the merchant; but he is ensorcelled by his stepdame who
bewitched both him and his mother: such is the cause of my
laughing; now the reason of his weeping is his mother, for that his
father slew her unawares. Then I marvelled at this with exceeding
marvel and hardly made sure that day had dawned before I came to
tell thee." When I heard, O Jinni, my herdsman's words, I went out
with him, and I was drunken without wine, from the excess of joy
and gladness which came upon me, until I reached his house. There
his daughter welcomed me and kissed my hand, and forthwith the
calf came and fawned upon me as before. Quoth I to the herdsman's
daughter, "Is this true that thou sayest of this calf?" Quoth she,
"Yea, O my master, he is thy son, the very core of thy heart." I
rejoiced and said to her, "O maiden, if thou wilt release him thine
shall be whatever cattle and property of mine are under thy father's
hand." She smiled and answered, "O my master, I have no greed for
the goods nor will I take them save on two conditions; the first that
thou marry me to thy son and the second that I may bewitch her
who bewitched him and imprison her, otherwise I cannot be safe
from her malice and malpractices." Now when I heard, O Jinni,
these, the words of the herdsman's daughter, I replied, "Beside what
thou askest all the cattle and the household stuff in thy father's
charge are thine and, as for the daughter of my uncle, her blood is
lawful to thee." When I had spoken, she took a cup and filled it with
water: then she recited a spell over it and sprinkled it upon the calf,
saying, "If Almighty Allah created thee a calf, remain so shaped, and
change not; but if thou be enchanted, return to thy whilom form, by
command of Allah Most Highest!" and lo! he trembled and became a
man. Then I fell on his neck and said, "Allah upon thee, tell me all
that the daughter of my uncle did by thee and by thy mother." And
when he told me what had come to pass between them I said, "O
my son, Allah favoured thee with one to restore thee, and thy right
hath returned to thee." Then, O Jinni, I married the herdsman's
daughter to him, and she transformed my wife into this gazelle,
saying:—Her shape is a comely and by no means loathsome. After
this she abode with us night and day, day and night, till the Almighty
took her to Himself. When she deceased, my son fared forth to the
cities of Hind, even to the city of this man who hath done to thee
what hath been done;[51] and I also took this gazelle (my cousin) and
wandered with her from town to town seeking tidings of my son, till
Destiny drove me to this place where I saw the merchant sitting in
tears. Such is my tale! Quoth the Jinni, "This story is indeed strange,
and therefore I grant thee the third part of his blood." Thereupon
the second old man, who owned the two greyhounds, came up and
said, "O Jinni, if I recount to thee what befel me from my brothers,
these two hounds, and thou see that it is a tale even more wondrous
and marvellous than what thou hast heard, wilt thou grant to me
also the third of this man's blood?" Replied the Jinni, "Thou hast my
word for it, if thine adventures be more marvellous and wondrous."
Thereupon he thus began
THE SECOND SHAYKH'S STORY.
Know, O lord of the Kings of the Jann! that these two dogs are my
brothers and I am the third. Now when our father died and left us a
capital of three thousand gold pieces,[52] I opened a shop with my
share, and bought and sold therein, and in like guise did my two
brothers, each setting up a shop. But I had been in business no long
while before the elder sold his stock for a thousand dinars, and after
buying outfit and merchandise, went his ways to foreign parts. He
was absent one whole year with the caravan; but one day as I sat in
my shop, behold, a beggar stood before me asking alms, and I said
to him, "Allah open thee another door!"[53] Whereupon he answered,
weeping the while, "Am I so changed that thou knowest me not?"
Then I looked at him narrowly, and lo! it was my brother, so I rose to
him and welcomed him; then I seated him in my shop and put
questions concerning his case. "Ask me not," answered he; "my
wealth is awaste and my state hath waxed un-stated!" So I took him
to the Hammám-bath[54] and clad him in a suit of my own and gave
him lodging in my house. Moreover, after looking over the accounts
of my stock-in-trade and the profits of my business, I found that
industry had gained me one thousand dinars, while my principal, the
head of my wealth, amounted to two thousand. So I shared the
whole with him, saying, "Assume that thou hast made no journey
abroad but hast remained at home; and be not cast down by thine
ill-luck." He took the share in great glee and opened for himself a
shop; and matters went on quietly for a few nights and days. But
presently my second brother (yon other dog), also setting his heart
upon travel, sold off what goods and stock-in-trade he had, and
albeit we tried to stay him he would not be stayed: he laid in an
outfit for the journey, and fared forth with certain wayfarers. After
an absence of a whole year he came back to me, even as my elder
brother had come back; and when I said to him, "O my brother, did I
not dissuade thee from travel?" he shed tears and cried, "O my
brother, this be destiny's decree: here I am a mere beggar,
penniless[55] and without a shirt to my back." So I led him to the
bath, O Jinni, and clothing him in new clothes of my own wear, I
went with him to my shop and served him with meat and drink.
Furthermore I said to him, "O my brother, I am wont to cast up my
shop-accounts at the head of every year, and whatso I shall find of
surplusage is between me and thee."[56] So I proceeded, O Ifrit, to
strike a balance and, finding two thousand dinars of profit, I
returned praises to the Creator (be He extolled and exalted!) and
made over one half to my brother, keeping the other to myself.
Thereupon he busied himself with opening a shop and on this wise
we abode many days. After a time my brothers began pressing me
to travel with them; but I refused, saying, "What gained ye by your
voyage that I should gain thereby?" As I would not give ear to them
we went back each to his own shop where we bought and sold as
before. They kept urging me to travel for a whole twelvemonth, but
I refused to do so till full six years were past and gone when I
consented with these words, "O my brothers, here am I, your
companion of travel: now let me see what monies you have by you."
I found, however, that they had not a doit, having squandered their
substance in high diet and drinking and carnal delights. Yet I spoke
not a word of reproach; so far from it I looked over my shop
accounts once more, and sold what goods and stock-in trade were
mine; and, finding myself the owner of six thousand ducats, I gladly
proceeded to divide that sum into halves, saying to my brothers,
"These three thousand gold pieces are for me and for you to trade
withal," adding, "Let us bury the other moiety underground that it
may be of service in case any harm befal us, in which case each
shall take a thousand wherewith to open shops." Both replied, "Right
is thy recking;" and I gave to each one his thousand gold pieces,
keeping the same sum for myself, to wit, a thousand dinars. We then
got ready suitable goods and hired a ship and, having embarked our
merchandise, proceeded on our voyage, day following day, a full
month, after which we arrived at a city, where we sold our venture;
and for every piece of gold we gained ten. And as we turned again
to our voyage we found on the shore of the sea a maiden clad in
worn and ragged gear, and she kissed my hand and said, "O master,
is there kindness in thee and charity? I can make thee a fitting
return for them." I answered, "Even so; truly in me are benevolence
and good works, even though thou render me no return." Then she
said, "Take me to wife, O my master, and carry me to thy city, for I
have given myself to thee; so do me a kindness and I am of those
who be meet for good works and charity: I will make thee a fitting
return for these and be thou not shamed by my condition." When I
heard her words, my heart yearned towards her, in such sort as
willed it Allah (be He extolled and exalted!); and took her and
clothed her and made ready for her a fair resting-place in the vessel,
and honourably entreated her. So we voyaged on, and my heart
became attached to her with exceeding attachment, and I was
separated from her neither night nor day, and I paid more regard to
her than to my brothers. Then they were estranged from me, and
waxed jealous of my wealth and the quantity of merchandise I had,
and their eyes were opened covetously upon all my property. So
they took counsel to murder me and seize my wealth, saying, "Let
us slay our brother and all his monies will be ours;" and Satan made
this deed seem fair in their sight; so when they found me in privacy
(and I sleeping by my wife's side) they took us both up and cast us
into the sea. My wife awoke startled from her sleep and, forthright
becoming an Ifritah,[57] she bore me up and carried me to an island
and disappeared for a short time; but she returned in the morning
and said "Here am I, thy faithful slave, who hath made thee due
recompense; for I bore thee up in the waters and saved thee from
death by command of the Almighty. Know that I am a Jinniyah, and
as I saw thee my heart loved thee by will of the Lord, for I am a
believer in Allah and in His Apostle (whom Heaven bless and
preserve!). Thereupon I came to thee conditioned as thou sawest
me and thou didst marry me, and see now I have saved thee from
sinking. But I am angered against thy brothers and assuredly I must
slay them." When I heard her story I was surprised and, thanking
her for all she had done, I said, "But as to slaying my brothers this
must not be." Then I told her the tale of what had come to pass
with them from the beginning of our lives to the end, and on hearing
it quoth she, "This night will I fly as a bird over them and will sink
their ship and slay them." Quoth I, "Allah upon thee, do not thus, for
the proverb saith, O thou who doest good to him that doth evil,
leave the evil doer to his evil deeds. Moreover they are still my
brothers." But she rejoined, "By Allah, there is no help for it but I
slay them." I humbled myself before her for their pardon,
whereupon she bore me up and flew away with me till at last she set
me down on the terrace-roof of my own house. I opened the doors
and took up what I had hidden in the ground; and after I had
saluted the folk I opened my shop and bought me merchandise.
Now when night came on I went home, and there I saw these two
hounds tied up; and, when they sighted me, they arose and whined
and fawned upon me; but ere I knew what happened my wife said,
"These two dogs be thy brothers!" I answered, "And who hath done
this thing by them?" and she rejoined, "I sent a message to my
sister and she entreated them on this wise, nor shall these two be
released from their present shape till ten years shall have passed."
And now I have arrived at this place on my way to my wife's sister
that she may deliver them from this condition, after their having
endured it for half a score of years. As I was wending onwards I saw
this young man, who acquainted me with what had befallen him,
and I determined not to fare hence until I should see what might
occur between thee and him. Such is my tale! Then said the Jinni,
"Surely this is a strange story and therefor I give thee the third
portion of his blood and his crime." Thereupon quoth the third
Shaykh, the master of the mare-mule, to the Jinni, "I can tell thee a
tale more wondrous than these two, so thou grant me the remainder
of his blood and of his offence," and the Jinni answered, "So be it!"
Then the old man began
THE THIRD SHAYKH'S STORY.
Know, O Sultan and head of the Jann, that this mule was my wife.
Now it so happened that I went forth and was absent one whole
year; and when I returned from my journey I came to her by night,
and saw a black slave lying with her on the carpet-bed, and they
were talking, and dallying, and laughing, and kissing and playing the
close-buttock game. When she saw me, she rose and came hurriedly
at me with a gugglet[58] of water; and, muttering spells over it, she
besprinkled me and said, "Come forth from this thy shape into the
shape of a dog;" and I became on the instant a dog. She drove me
out of the house, and I ran through the doorway nor ceased running
until I came to a butcher's stall, where I stopped and began to eat
what bones were there. When the stall-owner saw me, he took me
and led me into his house, but as soon as his daughter had sight of
me she veiled her face from me, crying out, "Dost thou bring men to
me and dost thou come in with them to me?" Her father asked,
"Where is the man?"; and she answered, "This dog is a man whom
his wife hath ensorcelled and I am able to release him." When her
father heard her words, he said, "Allah upon thee, O my daughter,
release him." So she took a gugglet of water and, after uttering
words over it, sprinkled upon me a few drops, saying, "Come forth
from that form into thy former form." And I returned to my natural
shape. Then I kissed her hand and said, "I wish thou wouldest
transform my wife even as she transformed me." Thereupon she
gave me some water, saying, "As soon as thou see her asleep,
sprinkle this liquid upon her and speak what words thou heardest
me utter, so shall she become whatsoever thou desirest." I went to
my wife and found her fast asleep; and, while sprinkling the water
upon her, I said, "Come forth from that form into the form of a
mare-mule." So she became on the instant a she-mule, and she it is
whom thou seest with thine eyes, O Sultan and head of the Kings of
the Jann! Then the Jinni turned towards her and said, "Is this
sooth?" And she nodded her head and replied by signs, "Indeed, 'tis
the truth: for such is my tale and this is what hath befallen me."
Now when the old man had ceased speaking the Jinni shook with
pleasure and gave him the third of the merchant's blood.——And
Shahrazad perceived the dawn of day and ceased saying her
permitted say. Then quoth Dunyazad, "O, my sister, how pleasant is
thy tale, and how tasteful; how sweet and how grateful!" She
replied, "And what is this compared with that I could tell thee, the
night to come, if I live and the King spare me?"[59] Then thought the
King, "By Allah, I will not slay her until I hear the rest of her tale, for
truly it is wondrous." So they rested that night in mutual embrace
until the dawn. After this the King went forth to his Hall of Estate,
and the Wazir and the troops came in and the court was crowded,
and the King gave orders and judged and appointed and deposed,
bidding and forbidding during the rest of the day. Then the Divan
broke up, and King Shahryar entered his palace.

Now when it was the Third Night,

And the King had had his will of the Wazir's daughter, Dunyazad, her
sister, said to her, "Finish for us that tale of thine;" and she replied,
"With joy and goodly gree! It hath reached me, O auspicious King,
that when the third old man told a tale to the Jinni more wondrous
than the two preceding, the Jinni marvelled with exceeding marvel;
and, shaking with delight, cried, "Lo! I have given thee the
remainder of the merchant's punishment and for thy sake have I
released him." Thereupon the merchant embraced the old men and
thanked them, and these Shaykhs wished him joy on being saved
and fared forth each one for his own city. Yet this tale is not more
wondrous than the fisherman's story." Asked the King, "What is the
fisherman?s story?" And she answered by relating the tale of

40. Travellers tell of a peculiar knack of jerking the date-stone,


which makes it strike with great force: I never saw this "Inwá"
practised, but it reminds me of the water-splashing with one
hand in the German baths.

41. i.e., sorely against his will.

42. Arab. "Shaykh"=an old man (primarily), an elder, a chief (of


the tribe, guild, etc.); and honourably addressed to any man.
Comp. among the neo-Latins "Sieur," "Signore," "Señor,"
"Senhor," etc. from Lat. "Senior," which gave our "Sire" and
"Sir." Like many in Arabic the word has a host of different
meanings and most of them will occur in the course of The
Nights. Ibrahim (Abraham) was the first Shaykh or man who
became grey. Seeing his hairs whiten he cried, "O Allah what is
this?" and the answer came that it was a sign of dignified
gravity. Hereupon he exclaimed, "O Lord increase this to me!"
and so it happened till his locks waxed snowy white at the age
of one hundred and fifty. He was the first who parted his hair,
trimmed his mustachios, cleaned his teeth with the Miswák
(tooth-stick), pared his nails, shaved his pecten, snuffed up
water, used ablution after stool and wore a shirt (Tabari).

43. The word is mostly plural=Jinnís: it is also singular=a demon;


and Ján bin Ján has been noticed.

44. With us moderns "liver" suggests nothing but malady: in Arabic


and Persian as in the classic literature of Europe it is the seat
of passion, the heart being that of affection. Of this more
presently.

45. Originally in Al-Islam the concubine (Surriyat, etc.) was a


captive taken in war and the Koran says nothing about buying
slave-girls. But if the captives were true believers the Moslem
was ordered to marry not to keep them. In modern days
concubinage has become an extensive subject. Practically the
disadvantage is that the slave-girls, knowing themselves to be
the master's property, consider him bound to sleep with them;
which is by no means the mistress's view. Some wives,
however, when old and childless, insist, after the fashion of
Sarah, upon the husband taking a young concubine and treat
her like a daughter—which is rare. The Nights abound in tales
of concubines, but these are chiefly owned by the Caliphs and
high officials who did much as they pleased. The only
redeeming point in the system is that it obviated the necessity
of prostitution which is, perhaps, the greatest evil known to
modern society.

46. Arab. "Al-Kahánah"=the craft of a "Káhin" (Heb. Cohen) a


diviner, soothsayer, etc.

47. Arab. "Id al-kabír"=The Great Festival; the Turkish Bayrám and
Indian Bakar-eed (Kine-fête), the pilgrimage-time, also termed
"Festival of the Kurbán" (sacrifice) because victims are slain;
Al-Zuha (of Undurn or forenoon), Al-Azhá (of serene night) and
Al-Nahr (of throat-cutting). For full details I must refer readers
to my "Personal Narrative of a Pilgrimage to El-Medinah and
Meccah" (3 vols. 8vo. London, Longmans, 1855). I shall have
often to refer to it.

48. Arab. "Kalám al-mubáh," i.e., that allowed or permitted to her


by the King, her husband.

49. Moslem Kings are expected, like the old Guebre Monarchs, to
hold "Darbar" (i.e., give public audience) at least twice a day,
morning and evening. Neglect of this practice caused the ruin
of the Caliphate and of the Persian and Moghul Empires: the
great lords were left uncontrolled and the lieges revolted to
obtain justice. The Guebre Kings had two levée places, the
Rozistan (day station) and the Shabistan (night-station—istán
or stán being a nominal form of istádan, to stand, as Hindo-
stán). Moreover one day in the week the sovereign acted as
"Mufti" or Supreme Judge.
50. Arab. "Al-Bashárah," the gift everywhere claimed in the East
and in Boccaccio's Italy by one who brings good news. Those
who do the reverse expose themselves to a sound strappado.

51. A euphemistic formula, to avoid mentioning unpleasant


matters. I shall note these for the benefit of students who
would honestly prepare for the public service in Moslem lands.

52. Arab. "Dinár," from the Latin denarius (a silver coin worth ten
ounces of brass) through the Greek δηνάριον: it is a Koranic
word (chapt. iii.) though its Arab equivalent is "Miskál." It also
occurs in the Kathá before quoted, clearly showing the
derivation. In the "Book of Kalilah and Dimnah" it is
represented by the Daric or Persian Dinár, δαρεικός, from
Dárá=a King (whence Darius). The Dinar, sequin or ducat,
contained at different times from 10 and 12 (Abu Hanifah's
day) to 20 and even 25 dirhams or drachmas; and, as a
weight, represented a drachma and a half. Its value greatly
varied, but we may assume it here at nine shillings or ten
francs to half a sovereign. For an elaborate article on the Dinar
see Yule's "Cathay and the Way Thither" (ii., pp. 439-443).

53. The formula used in refusing alms to an "asker" or in rejecting


an insufficient offer: "Allah will open to thee!" (some door of
gain—not mine)! Another favourite ejaculation is "Allah Karim"
(which Turks pronounce "Kyereem")=Allah is All-beneficent:
meaning Ask Him, not me.

54. The public bath. London knows the word through "The
Hummums."

55. Arab. "Dirham" (Plur. diráhim, also used in the sense of money,
"siller"), the Gr. δραχμή and the drachuma of Plautus (Trin. 2,
4, 23). The word occurs in the Panchatantra also showing the
derivation; and in the Syriac Kalilah wa Dimnah it is "Zúz." This
silver piece was=6 obols (9¾d.) and as a weight=66½ grains.
The Dirham of The Nights was worth six "Dánik," each of these
being a fraction over a penny. The modern Greek Drachma
is=one franc.

56. In Arabic the speaker always puts himself first, even if he


address the King, without intending incivility.

57. A she-Ifrit, not necessarily an evil spirit.

58. Arab. "Kullah" (in Egypt pron. "gulleh"), the wide-mouthed jug,
called in the Hijaz "baradiyah;" "daurak" being the narrow.
They are used either for water or sherbet and, being made of
porous clay, "sweat," and keep the contents cool; hence all old
Anglo-Egyptians drink from them, not from bottles. Sometimes
they are perfumed with smoke of incense, mastich or Kafal
(Amyris Kafal). For their graceful shapes See Lane's "Account
of the Manners and Customs of the Modern Egyptians" (chapt.
v). I quote, here and elsewhere, from the fifth edition, London,
Murray, 1860.

59. "And what is?" etc. A popular way of expressing great


difference. So in India:—"Where is Rajah Bhoj (the great King)
and where is Gangá the oilman?"
THE FISHERMAN AND THE JINNI.

It hath reached me, O auspicious King, that there was a Fisherman


well stricken in years who had a wife and three children, and withal
was of poor condition. Now it was his custom to cast his net every
day four times, and no more. On a day he went forth about
noontide to the sea shore, where he laid down his basket; and,
tucking up his shirt and plunging into the water, made a cast with
his net and waited till it settled to the bottom. Then he gathered
the cords together and haled away at it, but found it weighty; and
however much he drew it landwards, he could not pull it up; so he
carried the ends ashore and drove a stake into the ground and
made the net fast to it. Then he stripped and dived into the water
all about the net, and left not off working hard until he had brought
it up. He rejoiced thereat and, donning his clothes, went to the net,
when he found in it a dead jackass which had torn the meshes.
Now when he saw it, he exclaimed in his grief, "There is no Majesty,
and there is no Might save in Allah the Glorious, the Great!" Then
quoth he, "This is a strange manner of daily bread;" and he began
reciting in extempore verse:—
O toiler through the glooms of night in peril and in pain ✿ Thy toiling stint for
daily bread comes not by might and main!
Seest thou not the fisher seek afloat upon the sea ✿ His bread, while glimmer
stars of night as set in tangled skein.
Anon he plungeth in despite the buffet of the waves ✿ The while to sight the
bellying net his eager glances strain;
Till joying at the night's success, a fish he bringeth home ✿ Whose gullet by the
hook of Fate was caught and cut in twain.
When buys that fish of him a man who spent the hours of night ✿ Reckless of
cold and wet and gloom in ease and comfort fain,
Laud to the Lord who gives to this, to that denies his wishes ✿ And dooms one
toil and catch the prey and other eat the fishes.[60]

Then quoth he, "Up and to it; I am sure of His beneficence,


Inshallah!" So he continued:—
When thou art seized of Evil Fate, assume ✿ The noble soul's long-suffering: 'tis
thy best:
Complain not to the creature; this be 'plaint ✿ From one most Ruthful to the
ruthlessest.

The Fisherman, when he had looked at the dead ass, got it free of
the toils and wrung out and spread his net; then he plunged into the
sea, saying, "In Allah's name!" and made a cast and pulled at it, but
it grew heavy and settled down more firmly than the first time. Now
he thought that there were fish in it, and he made it fast, and
doffing his clothes went into the water, and dived and haled until he
drew it up upon dry land. Then found he in it a large earthen pitcher
which was full of sand and mud; and seeing this he was greatly
troubled and began repeating these verses[61]:—
Forbear, O troubles of the world, ✿ And pardon an ye nill forbear:
I went to seek my daily bread ✿ I find that breadless I must fare:
For neither handcraft brings me aught ✿ Nor Fate allots to me a share:
How many fools the Pleiads reach ✿ While darkness whelms the wise and ware.

So he prayed pardon of Allah and, throwing away the jar, wrung his
net and cleansed it and returned to the sea the third time to cast his
net and waited till it had sunk. Then he pulled at it and found
therein potsherds and broken glass; whereupon he began to speak
these verses:—
He is to thee that daily bread thou canst nor loose nor bind ✿ Nor pen nor writ
avail thee aught thy daily bread to find:
For joy and daily bread are what Fate deigneth to allow; ✿ This soil is sad and
sterile ground, while that makes glad the hind.
The shafts of Time and Life bear down full many a man of worth ✿ While bearing
up to high degree wights of ignoble mind.
So come thou, Death! for verily life is not worth a straw ✿ When low the falcon
falls withal the mallard wings the wind:
No wonder 'tis thou seest how the great of soul and mind ✿ Are poor, and many
a losel carle to height of luck designed.
This bird shall overfly the world from east to furthest west ✿ And that shall win
her every wish though ne'er she leave the nest.

Then raising his eyes heavenwards he said, "O my God!"[62] verily


Thou wottest that I cast not my net each day save four times;[63] the
third is done and as yet Thou hast vouchsafed me nothing. So this
time, O my God, deign give me my daily bread. Then, having called
on Allah's name,[64] he again threw his net and waited its sinking and
settling; whereupon he haled at it but could not draw it in for that it
was entangled at the bottom. He cried out in his vexation "There is
no Majesty and there is no Might save in Allah!" and he began
reciting:—
Fie on this wretched world, an so it be ✿ I must be whelmed by grief and
misery:
Tho' gladsome be man's lot when dawns the morn ✿ He drains the cup of woe
ere eve he see:
Yet was I one of whom the world when asked ✿ "Whose lot is happiest?" oft
would say "'Tis he!"
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