100% found this document useful (3 votes)
18 views

Optimizing Visual Studio Code for Python Development: Developing More Efficient and Effective Programs in Python 1st Edition Sufyan Bin Uzayr - Download the ebook now for the best reading experience

The document promotes various eBooks available for download at ebookmeta.com, particularly focusing on 'Optimizing Visual Studio Code for Python Development' by Sufyan Bin Uzayr. It outlines the features of Visual Studio Code, including its user interface and setup for Python development, along with chapters detailing various aspects of using Python with VS Code. Additional recommended eBooks cover topics from mastering Visual Studio Code to understanding frameworks like Django and Flask.

Uploaded by

nolotygvero
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (3 votes)
18 views

Optimizing Visual Studio Code for Python Development: Developing More Efficient and Effective Programs in Python 1st Edition Sufyan Bin Uzayr - Download the ebook now for the best reading experience

The document promotes various eBooks available for download at ebookmeta.com, particularly focusing on 'Optimizing Visual Studio Code for Python Development' by Sufyan Bin Uzayr. It outlines the features of Visual Studio Code, including its user interface and setup for Python development, along with chapters detailing various aspects of using Python with VS Code. Additional recommended eBooks cover topics from mastering Visual Studio Code to understanding frameworks like Django and Flask.

Uploaded by

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

Read Anytime Anywhere Easy Ebook Downloads at ebookmeta.

com

Optimizing Visual Studio Code for Python


Development: Developing More Efficient and
Effective Programs in Python 1st Edition Sufyan
Bin Uzayr
https://ebookmeta.com/product/optimizing-visual-studio-code-
for-python-development-developing-more-efficient-and-
effective-programs-in-python-1st-edition-sufyan-bin-uzayr/

OR CLICK HERE

DOWLOAD EBOOK

Visit and Get More Ebook Downloads Instantly at https://ebookmeta.com


Recommended digital products (PDF, EPUB, MOBI) that
you can download immediately if you are interested.

Mastering Visual Studio Code: A Beginner’s Guide 1st


Edition Sufyan Bin Uzayr

https://ebookmeta.com/product/mastering-visual-studio-code-a-
beginners-guide-1st-edition-sufyan-bin-uzayr/

ebookmeta.com

Visual Studio Code for Python Programmers 1st Edition


April Speight

https://ebookmeta.com/product/visual-studio-code-for-python-
programmers-1st-edition-april-speight/

ebookmeta.com

Mastering Python for Web: A Beginner's Guide (Mastering


Computer Science) 1st Edition Sufyan Bin Uzayr

https://ebookmeta.com/product/mastering-python-for-web-a-beginners-
guide-mastering-computer-science-1st-edition-sufyan-bin-uzayr/

ebookmeta.com

Mousetrap Structure and Meaning in Hamlet 1st Edition P J


Aldus

https://ebookmeta.com/product/mousetrap-structure-and-meaning-in-
hamlet-1st-edition-p-j-aldus/

ebookmeta.com
The Art Book First Edition Georgina Palffy Sam Atkinson

https://ebookmeta.com/product/the-art-book-first-edition-georgina-
palffy-sam-atkinson/

ebookmeta.com

A Beginner s Guide to Reading Tarot Cards A Helpful Guide


for Anybody with an Interest in Reading Cards 1st Edition
Anonymous
https://ebookmeta.com/product/a-beginner-s-guide-to-reading-tarot-
cards-a-helpful-guide-for-anybody-with-an-interest-in-reading-
cards-1st-edition-anonymous/
ebookmeta.com

Who Owns Haiti People Power and Sovereignty 1st Edition


Robert Maguire

https://ebookmeta.com/product/who-owns-haiti-people-power-and-
sovereignty-1st-edition-robert-maguire/

ebookmeta.com

Storey s Guide to Raising Pigs Care Facilities Management


Breeds 4th Edition Kelly Klober

https://ebookmeta.com/product/storey-s-guide-to-raising-pigs-care-
facilities-management-breeds-4th-edition-kelly-klober/

ebookmeta.com

Forging Identities The Mobility of Culture in Bronze Age


Europe Report from a Marie Curie Project 2009 2012 with
Concluding Conference at Aarhus University Moesgaard 2012
Volume 1 Paulina Suchowska Ducke Editor Samantha Scott
https://ebookmeta.com/product/forging-identities-the-mobility-of-
Reiter Editor Helle Vandkilde Editor
culture-in-bronze-age-europe-report-from-a-marie-curie-
project-2009-2012-with-concluding-conference-at-aarhus-university-
moesgaard-2012-volume-1-paulina-suchowska-du/
ebookmeta.com
Efficient MySQL Performance (Final Release) 1st Edition
Daniel Nichter

https://ebookmeta.com/product/efficient-mysql-performance-final-
release-1st-edition-daniel-nichter/

ebookmeta.com
Sufyan bin Uzayr

Optimizing Visual Studio Code for


Python Development
Developing More Efficient and Effective Programs
in Python
1st ed.
Sufyan bin Uzayr
Barabanki, India

ISBN 978-1-4842-7343-2 e-ISBN 978-1-4842-7344-9


https://doi.org/10.1007/978-1-4842-7344-9

© Sufyan bin Uzayr 2021

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.
For Mom
Introduction
Visual Studio Code (VS Code) is a great open-source code editor created
by Microsoft for Windows, Linux, and macOS. Widely applied, standard
features include support for debugging, syntax highlighting, automatic
code completion, snippets, code restructuring, and embedded Git.
Developers from all over the world are free to edit the design theme,
keyboard shortcuts, and preferences, as well as install essential and
extra extensions to upgrade the general project versatility.

Chapters at a Glance
Chapter 1, “Introduction to Visual Studio Code,” reviews how to set up
VS Code as well as provide an overview of the basic features, such as:
User interface: Provides the view of the documentation for VS Code.
Setup overview: Analyzes documentation for starting up and
running with VS Code, including platform-related setup.
Keyboard shortcuts: Provides customization options for your own
shortcuts and installation of Keymap extensions.
Keybinding extensions: Covers how to install a Keymap extension
and how to bring the keybindings from other editors to VS Code.
Chapter 2, “Getting Started with Python Programs in Visual Studio
Code,” explains in detail how to set up your VS Code for Python
Development. For the sake of demonstrating with examples, you’ll see
how to install most of the tools on Windows.
Chapter 3, “Setting Up the Environment and Testing,” demonstrates
how to install the top 8 Python extensions by typing Python in the
Extensions item on the Activity Bar.
Chapter 4, “Working with Python Frameworks,” discusses using
Python frameworks, such as Django and Flask. We will discuss topics
such as Python web development, Django apps, Flask development, and
so on.
Chapter 5, “Working with Containers and MS Azure,” covers Python
development in VS Code in assonance with MS Azure. Azure services
can be used for speedy deployment and building of production level
apps. With VS Code, Azure offers neat integration and this chapter
discusses the same.
Acknowledgments
There are many people who deserve to be on this page, for this book
would not have come into existence without their support. That said,
some names deserve a special mention, and I am genuinely grateful to:
My mother and father, for everything they have done for me.
Faisal Fareed and Sadaf Fareed, my siblings, for helping with things
back home.
Sana Akhtar Usmani, for all her help and support.
The Parakozm team, especially Madina Karybzhanova, for offering
great amounts of help and assistance during the book-writing
process.
The Apress team, especially Smriti Srivastava, Shrikant Vishwakarma,
and James Markham, for ensuring that the book’s content, layout,
formatting, and everything else remains perfect throughout.
Reviewers of this book, for going through the manuscript and
providing their insight and feedback.
Typesetters, cover designers, printers, and everyone else, for their
part in the development of this book.
All the folks associated with Zeba Academy, either directly or
indirectly, for their help and support.
The Python and VS Code community at large, for all their hard work
and efforts.

—Sufyan bin Uzayr


Table of Contents
Chapter 1:​Introduction to Visual Studio Code
User Interface
Basic Layout
Side-By-Side Editing
Minimap
Indent Guides
Breadcrumbs
Explorer
Multiselection
Filtering the Document Tree
Outline View
Markdown Outline View
Open Editors
Views
Activity Bar
Command Palette
Configuring the Editor
Hiding the Menu Bar (for Windows, Linux)
Settings
Zen Mode
Centered Editor Layout
Tabs
Tab Ordering
Preview Mode
Editor Groups
Keyboard Shortcuts
Disabling Preview Mode
Using Ctrl+Tab to Navigate in Entire Editor History
Closing an Entire Group Instead of a Single Editor
Window Management
Setting Up Visual Studio Code
Cross-Platform
Updating Cadence
Insiders Nightly Build
Portable Mode
Additional Components
Extensions
Key Bindings for Visual Studio Code
Keyboard Shortcuts Editor
Keyboard Rules
Accepted Keys
Command Arguments
Removing a Specific Key Binding Rule
Keyboard Layout-Independent Nindings
When Clause Contexts
Conditional Operators
Available Contexts
Programming Languages Supported
Language Features in VS Code
Changing the Language for the Selected File
Additional Components and Tools
Commonly Used Components
VS Code Extensions
Additional Tools
Settings Precedence
Settings and Security
Summary
Chapter 2:​Getting Started with Python Programs in Visual Studio
Code
Installation Basics
Reviewing the Required Extensions
Tabnine
Bracket Pair Colorizer
Python Snippets
Python Test Explorer for Visual Studio Code
Configuring Debug
Better Comments
AutoDocstring
Python Indent
Getting Started with Code Editing
Autocomplete and IntelliSense
Customizing IntelliSense Behavior
Troubleshooting
Running Selection/​Line in Terminal (REPL)
Formatting
Troubleshooting Your Formatting
Refactoring
Linting
Enabling Linters
Disabling Linting
Running Linting
Linting Settings
Pylint
Troubleshooting Linting
Debugging
Initializing Configurations
Additional Configurations
Basic Debugging
Conditional Breakpoints
Summary
Chapter 3:​Setting Up the Environment and Testing
Setting Up Your Environment
Manually Specifying an Interpreter
Selecting and Activating an Environment
Environments and Terminal Windows
Choosing a Debugging Environment
Environment Variable Definitions File
Variable Substitution
Using the PYTHONPATH Variable
Running Your Projects
Selecting a Python Interpreter
Creating a Python Hello World Source Code File
Running Hello World
Running the Python Debugger
Installing and Using Packages
Supportting Jupyter
Jupyter Code Cells
Additional Commands and Keyboard Shortcuts
Python Interactive Window
Plot Viewer
Live Share for Python Interactive
Variable Explorer and Data Viewer
Connecting to a Remote Jupyter Server
Converting Jupyter Notebooks to Python Code File
Debugging a Jupyter Notebook
Exporting a Jupyter Notebook
Configuration Files
Data Files
Runtime File
Summary
Chapter 4:​Working with Python Frameworks
Python Frameworks Ecosystem at a Glance
Django Development
Installation
Creating a Project Environment for the Django Tutorial
Creating and Running a Minimal Django App
Creating the Django Project
Creating a Django App
Creating a Debugger Launch Profile
Exploring the Debugger
Using Definition and Peek Definition Commands
Using a Template to Render a Page
Serving Static Files
Readying the App for Static Files
Referring to Static Files
Using the Collectstatic Command
Creating Multiple Templates That Extend a Base Template
Creating a Base Page Template and Styles
Creating a Code Snippet
Working with Data, Data Models, and Migrations
Types of Databases
Migrating the Database
Creating a Superuser and Enabling the Administrative
Interface
Flask Development
Creating and Running a Minimal Flask App
Running the App in the Debugger
Using Definition and Peek Definition Commands
Using a Template to Render a Page
Creating a Requirements.​txt File for the Environment
Data Science–Specific Information and Tutorials
Setting Up a Data Science Environment
Preparing the Data
Training and Evaluating a Model
Summary
Chapter 5:​Working with Containers and MS Azure
Integrating Azure for Your Python Projects
Key Azure Services
Creating a Function in Azure with Python Using Visual
Studio Code
Deploying Docker Containers to Azure App Service
Using Containers in VS Code
Operating with Containers
Creating a Devcontainer.​json File
Managing Extensions
Forcing an Extension to Operate Locally or Remotely
Forwarding or Publishing a Port
Temporarily Forwarding a Port
Personalizing with Dotfile Repositories
Summary
Index
About the Author
Sufyan bin Uzayr
is a writer, coder, and entrepreneur with over a decade of experience in
the industry. He has authored several books in the past on a diverse
range of topics, ranging from history to computers and information
technology.
Sufyan is the director of Parakozm, a multinational IT company
specializing in EdTech solutions. He also runs Zeba Academy, an online
learning and teaching vertical with a focus on STEM fields. He
specializes in a wide variety of technologies, such as JavaScript, Dart,
WordPress, Drupal, Linux, and Python. He holds multiple degrees, in
fields including management, information technology, literature, and
political science.
Sufyan is a digital nomad, dividing his time between four countries.
He has lived and taught in universities and educational institutions
around the globe. Sufyan takes a keen interest in technology, politics,
literature, history, and sports, and in his spare time, he enjoys teaching
coding and English to young students.
Learn more at sufyanism.com.
About the Technical Reviewer
Mathew Rooney
is a coder with 8 years of experience in the web development field. He
works with PHP, JavaScript, Python, and offers custom-coded
WordPress themes and plugins. Mathew is a firm believer in open-
source software and has finished Bachelor of Technology in computer
science.
© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2021
S. bin Uzayr, Optimizing Visual Studio Code for Python Development
https://doi.org/10.1007/978-1-4842-7344-9_1

1. Introduction to Visual Studio Code


Sufyan bin Uzayr1
(1) Barabanki, India

Visual Studio Code (VS Code) is an open-source code editor created by


Microsoft for Windows, Linux, and macOS (Figure 1-1). Widely popular
standard features include support for debugging, syntax highlighting,
automatic code completion, snippets, code restructuring, and embedded Git.
Users are free to change the design theme, keyboard shortcuts, and
preferences, as well as install additional extensions to upgrade the overall
project functionality.
Microsoft first introduced VS Code at the 2015 Build conference. By 2019
VS Code ranked as the most popular developer environment tool, with 50.7%
of 87,317 respondents reporting that they regularly apply it.

Figure 1-1 Visual Studio Code, a free and open-source code editor
In this chapter, we will walk you through setting up VS Code as well as
provide an overview of the basic features:
User interface: viewing the documentation for VS Code.
Setup overview: documentation for starting up and running with VS Code,
including platform-related setup.
Keyboard shortcuts: customization options for your own shortcuts and
installation of Keymap extensions.
Keybinding extensions: how to install a Keymap extension to bring the
keybindings from your previous editor to VS Code.

User Interface
According to the original intent, VS Code is a code editor. Similar to many other
code editors, VS Code has a common user interface and layout of an explorer
on the left, displaying all of the files and folders you have access to, and an
editor on the right, presenting the content of the files you have opened.

Basic Layout
VS Code comes with a straightforward yet intuitive layout that utilizes all the
space provided for the editor, while leaving some room to browse and access
the full context of your folder or the ongoing project. The User Interface is
divided into five main areas:
Editor: The main space for you to edit current files. You can open as many
editors as you need side by side, as well as vertically and horizontally.
SideBar: This area has different views such as the Explorer, to provide a
maximum assistance while you are working on your project.
Status Bar: Information about the current project and the files you are
editing.
Activity Bar: Placed on the far left-hand side, this area enables you to switch
between views and gives you additional context-specific measures—for
instance, the number of outgoing changes.
Panels: You can show different panels below the editor area for output or
debug content, errors, and warnings, or integrated information. The panel
can also be shifted to the right for more vertical space.
Each time you launch VS Code, it opens up in the same state it was in when
you last left it. The folder, layout, and opened files will be preserved the same.
Open files in each editor are displayed with tabbed headers (Tabs) at the top of
the editor region. To learn more information about tabbed headers, see the
details of the Tabs section. You can also move the Sidebar to the right-hand
side (View ➤ Move Side Bar Right) or enhance its visibility (Ctrl+B).

Side-By-Side Editing
As previously mentioned, you can open as many editors as you like side-by-
side vertically as well as horizontally. If you already have one editor open,
there are various ways of placing another editor to the side of the existing one:
Alt-click on a file in the Explorer.
Ctrl+\ to split the active editor into two.
Open to the Side (Ctrl+Enter) from the Explorer context menu on a file.
Click the Split Editor button in the upper right of an editor.
Drag and drop a file to any side of the editor region.
Ctrl+Enter (macOS: Cmd+Enter) in the Quick Open (Ctrl+P) file list.
Once you open another file, the editor that is in progress will display the
content of that file. So if you have two editors side by side and you need to
open file doc.cs into the right-hand editor, make sure that editor is active (by
clicking on it) before opening file doc.cs.
By default, editors are made to open on the right-hand side of the active
one. You can change this pattern through the setting
workbench.editor.openSideBySideDirection and modify to open new editors to
the bottom of the active one instead. At the same time, when you have more
than one editor active, you can switch between them easily by holding the Ctrl
(macOS: Cmd) key and pressing 1, 2, and 3. In addition, you can resize editors
and reorder them if you would like to: simply drag and drop the editor title
area to reposition or resize the editor.

Minimap
A Minimap (code outline) allows you to get a high-level overview of your
source code, which is quite useful for easy navigation and code
comprehension. A file’s minimap is displayed on the right side of the editor.
You can also click or drag the shaded area to quickly switch to different
sections of your file. It is also worth noting that you can move the minimap to
the left-hand side or even disable it completely by simply setting
“editor.minimap.side”:, “left”, or “editor.minimap.enabled”: false in your user or
workspace settings.

Indent Guides
The image above the editor also shows vertical lines or indentation guides that
are there to help you freely observe matching indent levels. If you would like to
turn off those indent guides, you should set “editor.renderIndentGuides”: false
in your user or workspace settings.

Breadcrumbs
If you take a look at the editor once again, you will notice it has a navigation
bar above its contents that is named Breadcrumbs. It is there to show your
current location and let you quickly navigate between folders, files, and
symbols.
Breadcrumbs also tend to display the file path, and if the active file type has
language support for symbols, it displays the symbol path up to the cursor
position. You can switch off Breadcrumbs with the View ➤ Show Breadcrumbs
simple command. You can also access the same information about the
Breadcrumbs feature at the Breadcrumbs section of the editor.

Explorer
The Explorer is a tool used to browse, open, and operate all of the files and
folders in your editing project. Since VS Code is file- and folder-based, you can
get started at any time simply by opening a file or folder in VS Code. Once you
open a folder in VS Code, the contents of the folder are shown in the Explorer.
You can do many modifications from here, such as:
Create, delete, and rename files and folders.
Change the location of files and folders by using drag and drop.
See the context menu to see all options.
Moreover, you can drag and drop files into the Explorer from outside VS
Code to make a VS copy of them, so that if the explorer is empty, VS Code will
access them instead.
VS Code also works very well with other tools that you might use,
especially command-line tools. If you need to run a command-line tool in the
context of the folder you have open in VS Code, right-click the folder and select
Open in Command Prompt (or Open in Terminal on macOS or Linux).
At the same time, you can navigate to the location of a file or folder in the
native Explorer by right-clicking on a file or folder and selecting Reveal in
Explorer (or Reveal in Finder on macOS, or Open Containing Folder on Linux).
You may also type Ctrl+P (Quick Open option) to quickly search and open a file
by its name.
By default, VS Code does not open some folders from the Explorer (for
example, .git). In this case, you can use the files.exclude setting to edit rules for
hiding files and folders from the Explorer. However, if you have any derived
resource files, such as \*.meta in Unity or \*.js in a TypeScript project, then
this solution is not really going to be useful. Please note that for Unity to
exclude the \*.cs.metafiles, the pattern to select would be “**/*.cs.meta”: true.
For TypeScript, you can exclude generated JavaScript for TypeScript files with
“**/*.js”: {“when”: “$(basename).ts”}.

Multiselection
You can choose multiple files in the File Explorer and OPEN EDITORS view to
complete actions (Delete, Drag and Drop, Open to the Side) on multiple items.
Simply use the Ctrl/Cmd key with a click to select individual files and Shift +
click to select a range. If you select two items, you can now use the context
menu Compare Selected command to quickly differentiate the two files. Also,
remember that in earlier VS Code releases, clicking with the Ctrl/Cmd key
pressed would open a file in a new Editor Group to the side. If you would still
like this feature, you can use the workbench.list.multiSelectModifier setting to
modify multiselection to use the Alt key by
“workbench.list.multiSelectModifier”: “alt”.

Filtering the Document Tree


It is possible to filter the currently visible files in the File Explorer. You can
simply start typing part of the file name you want to match, keeping the focus
on the File Explorer. You will be able to see a filter box in the top-right of the
File Explorer presenting what you have typed so far, and matching file names
will be highlighted. Once you press the cursor keys to move up and down the
file list, it will switch between matching files or folders. However, switching
over the filter box and selecting Enable Filter on Type will show only matching
files and folders. You can apply the X Clear button to clear the filter.

Outline View
The Outline view is a section at the bottom of the File Explorer. When
activated, it will show the symbol tree of the currently active editor. The
Outline view has different Sort By modes and optional cursor tracking, and
supports the usual open gestures. It also has an input box that can search for
filters and symbols as you type. Errors and warnings are also displayed in the
Outline view, allowing you to see a glimpse of a problem as well as its location.
As for symbols, the view relies heavily on the data computed by your
installed extensions for different file types. For instance, the built-in
Markdown support returns the Markdown header hierarchy for a Markdown
file’s symbols.
Markdown Outline View
There are a few Outline view settings that allow you to enable and disable
items and operate with errors and warnings display (all enabled by default):1
outline.icons: toggle rendering outline elements with icons.
outline.problems.enabled: shows errors and warnings on outline
elements.
outline.problems.badges: toggle using badges for errors and warnings.
outline.problems.colors: toggle using colors for errors and warnings.

Open Editors
At the top of the Explorer, there is a section labeled as OPEN EDITORS that
displays a list of active files or previews. There might also be some files visible
that you previously opened in VS Code. For example, a file will be listed in the
OPEN EDITORS view if you make a change to a file, double-click a file’s header,
double-click a file in the Explorer, or open a file that is not part of the current
folder. By clicking an item in the OPEN EDITORS view, it becomes active in VS
Code. Once you are finished with your project and wish to remove files
individually from the OPEN EDITORS view, or remove all files, you can do so by
using the View: Close All Editors or View and then Close All Editors in Group
actions.

Views
The File Explorer is just one of the Views available in VS Code. There are also
Views for:2
Search: Provides global search and replace across your open folder.
Source Control: VS Code includes Git source control by default.
Run: VS Code’s Run and Debug View displays variables, call stacks, and
breakpoints.
Extensions: Installs and manages your extensions within VS Code.
Custom views: Views contributed by extensions.
Any of these views can be accessed by using the View: Open View
command.

Activity Bar
The Activity Bar on your left is designed for you to easily switch between
Views. You can also reorder Views by dragging and dropping them on the
Activity Bar, or stow away a View entirely with the right-click Hide from
Activity Bar.
Command Palette
VS Code is also easily accessible from the keyboard. The most useful key
combination to know is Ctrl+Shift+P, which calls for the Command Palette.
With the Command Palette you have access to all of the functionality of VS
Code, including keyboard shortcuts for the most implemented operations. The
Command Palette provides access to many commands. You can manage editor
commands, open files, search for items, and see a quick outline of a file, all
while using the same interactive window. Following are a few navigation
combinations:3
Ctrl+P will let you navigate to any file or symbol by typing its name.
Ctrl+Tab will cycle you through the last set of files opened.
Ctrl+Shift+P will bring you directly to the editor commands.
Ctrl+Shift+O will let you navigate to a specific symbol in a file.
Ctrl+G will let you navigate to a specific line in a file.
Type ? into the input field to get a list of available commands you can
execute from Quick Open Help.

Configuring the Editor


VS Code has many options for you to configure the editor. From the View menu
you can hide or toggle various bits of the user interface, such as the Side Bar,
Status Bar, and Activity Bar.

Hiding the Menu Bar (for Windows, Linux)


You can hide the Menu Bar on Windows and Linux by selecting the setting
window.menuBarVisibility from classic to toggle. The toggle setting means that
a single press of the Alt key will show the Menu Bar again.
You can also remove the Menu Bar on Windows and Linux with the View ➤
Toggle Menu Bar command. This command switches
window.menuBarVisibility from classic to compact, resulting in the Menu Bar
moving into the Activity Bar. To move back to the Menu Bar to the classic
position, select the View ➤ Toggle Menu Bar command again.

Settings
Most basic editor configurations are kept in settings that can be modified
directly. You can set options globally through user settings, or per project or
file through workspace settings. Settings options are kept in a settings.json file.
You can follow the path Select File ➤ Preferences ➤ Settings (or press Ctrl+,)
to edit the user settings.json file. To change workspace settings, click the
WORKSPACE SETTINGS tab to edit the workspace settings.json file. Note that
for macOS users, the Preferences menu is located under Code, not File; please
follow Code ➤ Preferences ➤ Settings.
You can access the VS Code Default Settings in the left window, and your
editable settings.json on the right. It is also possible to easily filter settings in
the Default Settings using the search box at the top. You can copy a setting over
to the editable settings.json on the right by clicking on the edit icon to the left
of the setting. Settings with a fixed set of values let you select a primary value
as a section of their edit icon menu. After editing your settings, type Ctrl+S to
settle your changes. The changes will take effect instantly. Workspace settings
will override User settings and are beneficial for sharing particular project
settings.

Zen Mode
Zen mode enables you to focus on your code by removing all User Interface
items (Activity Bar, Status Bar, Side Bar, and Panel) except the editor, displaying
the full screen and centering the editor layout only. Zen mode can be toggled
using the View menu, Command Palette or by the shortcut, Ctrl+K Z. To exit
Zen mode, press double Esc. The transition to full screen can be disabled via
zenMode.fullScreen. Zen mode can be further modified using the following
settings: zenMode.hideStatusBar, zenMode.hideTabs, zenMode.fullScreen,
zenMode.restore, and zenMode.centerLayout.

Centered Editor Layout


Centered editor layout lets you center-align the editor area. This is especially
useful if you find yourself working with a single editor on a large monitor. You
can apply the sashes on the side to resize the view with the Alt key, and using
the same method you can also independently move the sashes.

Tabs
VS Code displays open items with tabbed headings or Tabs in the title area
above the editor. If you open a file, a new Tab is added for that file. Tabs allow
you to quickly navigate between files, and you can drag and drop tabs to
reorder them as you wish. When you have more open items than can fit in the
title area, you can apply the Show Opened Editors command to show a
dropdown list of tabbed items.
If you do not want to use Tabs, you can turn off the feature by setting the
workbench.editor.showTabs setting to false: “workbench.editor.showTabs”:
false.
Tab Ordering
By default, new Tabs are included to the right of the existing Tabs, but you can
administer where you would like new Tabs to appear with the
workbench.editor.openPositioning setting. For instance, you might like new
tabbed items to appear on the left, by using
“workbench.editor.openPositioning”: “left”.

Preview Mode
Once you single-click or select a file in the Explorer, it is shown in a
presentation mode and reuses an existing Tab. This is particularly helpful if
you just need to quickly browse files and do not want each file you accessed to
have its own Tab. When you start editing the file or use double-click to open
the file from the Explorer, a new Tab is assigned to that file. Preview mode is
indicated by italics in the Tab heading: preview mode.
If you would rather not see the preview mode and always make a new Tab,
you can control the pattern with these settings:
workbench.editor.enablePreview: to globally enable or disable preview
editors.
workbench.editor.enablePreviewFromQuickOpen: to enable or disable
preview editors when opened from Quick Open.

Editor Groups
If you split an editor via the Split Editor or Open to the Side commands, a new
editor region that can hold a group of items is created instead. At the same
time, you can open as many editor regions as you like side-by-side vertically
and horizontally. You can see them in order in the OPEN EDITORS section at
the top of the Explorer view. The OPEN EDITORS section also allows you to
Drag and Drop editor groups on the workbench, move individual Tabs between
groups, and quickly close entire groups by clicking on Close All.
Be sure that VS Code uses editor groups whether or not you have any Tabs
on. Without Tabs, editor groups are a stack of your open items with the most
recently searched item visible in the editor pane. By default, editor groups are
structured in vertical columns when you split an editor to open it to the side.
You can also arrange editor groups in any layout you like, both vertically and
horizontally.
In order to support flexible layouts, you should create empty editor groups.
By default, closing the last editor of an editor group will also close the group
itself, but you can modify this behavior with the new setting
workbench.editor.closeEmptyGroups: false. You can also see if there are any
predefined set of editor layouts in the View ➤ Editor Layout menu.
Editors that open to the side by clicking the editor toolbar Split Editor
action will normally open to the right-hand side of the active editor. If you
prefer to open editors below the active one, configure the new setting
workbench.editor.openSideBySideDirection: down.
There are plenty of keyboard commands for adjusting the editor layout
with the keyboard alone, but if you prefer to use the mouse, drag and drop is
the fastest method to split the editor into any direction. In addition, if you
press and hold the Alt key while switching over the toolbar action to split an
editor, it will offer to split to the other orientation. This is another fast way to
split either to the right or to the bottom.

Keyboard Shortcuts
It will also be very beneficial for you to know some handy keyboard shortcuts
to quickly navigate between editors and editor groups. Some of the most
widely used ones are the following:4
Ctrl+PageDown go to the right editor.
Ctrl+PageUp go to the left editor.
Ctrl+Tab open the previous editor in the editor group MRU list.
Ctrl+1 go to the leftmost editor group.
Ctrl+2 go to the center editor group.
Ctrl+3 go to the rightmost editor group.
Ctrl+F4 close the active editor.
Ctrl+K W close all editors in the editor group.
Ctrl+K Ctrl+W close all editors.

Disabling Preview Mode


Without Tabs, the OPEN EDITORS section of the File Explorer is a great way to
do file navigation. With preview editor mode, files are not shown in the OPEN
EDITOR list, nor editor group on single-click open. You can turn this feature off
through the workbench.editor.enablePreview and
workbench.editor.enablePreviewFromQuickOpen settings.

Using Ctrl+Tab to Navigate in Entire Editor History


You can edit keybindings for Ctrl+Tab to show you a list of all opened editors
from the history independent from the active editor group. You can edit your
keybindings and add the following by using:
{ "key": "ctrl+tab", "command":
"workbench.action.openPreviousEditorFromHistory" },
{ "key": "ctrl+tab", "command":
"workbench.action.quickOpenNavigateNext", "when":
"inQuickOpen" }

Closing an Entire Group Instead of a Single Editor


If you want to repeat the behavior of VS Code closing an entire group when
closing one editor, you can bind the following in your keybindings by using:

macOS: { "key": "cmd+w", "command":


"workbench.action.closeEditorsInGroup" }
Windows/Linux: { "key": "ctrl+w", "command":
"workbench.action.closeEditorsInGroup" }

Window Management
VS Code has some options to operate to determine how windows can be
opened or restored between sessions. The settings
window.openFoldersInNewWindow and window.openFilesInNewWindow are
used to configure opening new windows or reusing the last active window for
files or folders and possible values by default.
If edited to turn to default conditions, VS Code will restore all windows you
worked on during your previous session. However, there can still be cases
where this setting is ignored (for instance, if using the -new-window or -reuse-
window command-line option).
The window.restoreWindows setting tells VS Code how to restore the
opened windows of your previous session. You can also change this setting to
never reopen any windows and always start with an empty VS Code instance.
We will now take a look at how to set up VS Code for Python development.

Setting Up Visual Studio Code


Getting and activating VS Code is easy and quick. All it takes is a small
download and then you can install it in a matter of minutes (Figure 1-2).
Figure 1-2 Setting up VS Code

Cross-Platform
VS Code is a free code editor that runs on the macOS, Linux, and Windows
operating systems.
For smoother installation you can follow the following platform-specific
guides:5

MacOS
1. Download VS Code for macOS.

2. Open the browser’s download list and locate the downloaded archive.

3. Select the magnifying glass icon to open the archive in Finder.

4. Drag VS Code.app to the Applications folder, making it available in the


macOS Launchpad.

5. Add VS Code to your Dock by right-clicking on the icon to bring up the


context menu and choosing Options, Keep in Dock.

Linux
VS Code is officially distributed as a Snap package in the Snap Store, and can
also be downloaded from the official site as an RPM or DEB package.
You can install it by running: sudo snap install --classic code # or code-
insiders.
Once installed, the Snap daemon will take care of automatically updating
VS Code in the background. You can also expect to get an in-product update
notification whenever a new update is available.

Windows
1. Download the VS Code installer for Windows.

2. Once it is downloaded, run the installer (VSCodeUserSetup-{version}.exe).


This will only take a minute.

3. By default, VS Code is installed under C:\users\


{username}\AppData\Local\Programs\Microsoft VS Code.

VS Code is lightweight and should run on most available hardware and


platform versions. You can review the System Requirements to see whether
your computer configuration is supported.

Updating Cadence
VS Code releases a new version every month with new features and
progressive bug fixes. Most platforms have auto-updating installed, so you will
be prompted to look for the new release when it becomes available. You can
also manually check for updates by running Help ➤ Check for Updates on
Linux and Windows, or running Code ➤ Check for Updates on macOS.
Additionally, you can also disable auto-update if you would like to update VS
Code according to your own schedule.

Insiders Nightly Build


If you’d like to check out VS Code nightly builds to get access to new features
earlier than the rest of the users or to verify bug fixes, you can install the
Insiders build. The Insiders build installs side by side with the monthly Stable
build, and you can freely incorporate and work with both on the same
machine. The Insiders build is the same tool that the VS Code development
team uses on a daily basis. If you have valuable feedback about the new
features to offer, the development team would really appreciate it.

Portable Mode
VS Code also supports Portable mode installation. This mode ensures that all
data created and maintained by VS Code is stored in close quarters so that
when necessary it can be moved around across environments, even on a USB
drive.

Additional Components
VS Code is an editor with a relatively small footprint. Unlike other traditional
editors that tend to include every other function, with VS Code you can tune
and customize your installation to the development technologies most
important to you.

Extensions
VS Code extensions let third parties add support for the following:
Languages: C++, C#, Go, Java, Python
Tools: ESLint, JSHint , PowerShell
Debuggers: PHP XDebug
Keymaps: Vim, Sublime Text, IntelliJ, Emacs, Atom, Brackets, Visual Studio,
Eclipse
Extensions smoothly integrate into VS Code’s User Interface, commands,
and task running systems, so you will find it easy to operate with different
technologies through VS Code’s shared interface.

Key Bindings for Visual Studio Code


VS Code offers you an option to manage most tasks directly from the keyboard
(Figure 1-3). This section lists out the default bindings (keyboard shortcuts)
and gives you an overview of how you can update them.
Figure 1-3 Using keyboard shortcuts in VS Code

Keyboard Shortcuts Editor


VS Code has many simple keyboard shortcuts using Keyboard Shortcuts editor.
It illustrates all available commands with and without keybindings, and you
can easily change, remove, and update these using the available options. It also
has a search box on the top that is useful when searching for commands or
keybindings. You can open this editor by looking at the menu under File ➤
Preferences ➤ Keyboard Shortcuts (Code ➤ Preferences ➤ Keyboard
Shortcuts on macOS). You can also access a printable version of these keyboard
shortcuts at Help ➤ Keyboard Shortcut Reference and get a condensed PDF
version suitable for printing as a user-friendly reference.

Detecting Keybinding Conflicts


If you have too many extensions installed or you have customized most of your
keyboard shortcuts, you may at times face keybinding conflicts where the same
keyboard shortcut is mapped to perform several commands. This can result in
confusing occurrences, especially if different keybindings are going in and out
of scope when you keep working with the editor. From time to time you should
check on the Keyboard Shortcuts editor that has a context menu command
Show Same Keybindings, which is used to filter the keybindings based on a
keyboard shortcut to display and potentially prevent any conflicts.

Troubleshooting Keybindings
To troubleshoot keybindings problems, you can activate the command
Developer: Toggle Keyboard Shortcuts Troubleshooting. This will help to
perform logging of dispatched keyboard shortcuts and will give access to the
output panel with the corresponding log file.
With it, you can later press your desired keybinding and check what
keyboard shortcut VS Code uses and what command is activated.

Keyboard Rules
Each rule consists of the following:6
a key that defines the pressed keys.
a command containing the identifier of the command to execute.
an optional when clause containing a Boolean expression that will be
calculated depending on the current context.
Two separate keypress actions known as Chords are described by
separating the two keypresses with space. For example, Ctrl+K Ctrl+C.
When a key is pressed:
the rules are assessed from bottom to top.
the first rule that matches, both the key and in terms of when is accepted.
no more rules are processed.
if a rule is found and has a command set too, the command is implemented.
The additional keybindings.json rules are omitted at runtime to the bottom
of the default rules, therefore allowing them to overwrite the default rules. The
keybindings.json file is observed by VS Code, so editing it while VS Code is
running will upgrade the rules at runtime.
The keyboard shortcuts dispatching is completed by analyzing a list of
rules that are stored in JSON. To illustrate with a few examples:7

// Keybindings that are active when the focus is in the


editor:
{ "key": "home", "command":
"cursorHome", "when": "editorTextFocus" },
{ "key": "shift+home", "command":
"cursorHomeSelect", "when":
"editorTextFocus" },

// Keybindings that are complementary:


{ "key": "f5", "command":
"workbench.action.debug.continue", "when":
"inDebugMode" },
{ "key": "f5", "command":
"workbench.action.debug.start", "when":
"!inDebugMode" },

// Global keybindings:
{ "key": "ctrl+f", "command": "actions.find"
},
{ "key": "alt+left", "command":
"workbench.action.navigateBack" },
{ "key": "alt+right", "command":
"workbench.action.navigateForward" },

// Global keybindings using chords (two separate


keypress actions):
{ "key": "ctrl+k enter", "command":
"workbench.action.keepEditor" },
{ "key": "ctrl+k ctrl+w", "command":
"workbench.action.closeAllEditors" },

Accepted Keys
The key is made up of modifiers and the key itself. The following modifiers are
accepted:

Platform Modifiers
macOS Ctrl+, Shift+, Alt+, Cmd+
Windows Ctrl+, Shift+, Alt+, Win+
Linux Ctrl+, Shift+, Alt+, Meta+

The following keys are accepted:


f1-f19, a-z, 0-9
`, -, =, [, ], \, ;, ’, ,, ., /
left, up, right, down, pageup, pagedown, end, home
tab, enter, escape, space, backspace, delete
pausebreak, capslock, insert
numpad0-numpad9, numpad_multiply, numpad_add, numpad_separator
numpad_subtract, numpad_decimal, numpad_divide

Command Arguments
You can call on command with arguments. This is especially helpful if you
usually perform the same operation on a specific file or folder. You can include
a custom keyboard shortcut to do exactly what you need it to do. The following
is an example of overriding the Enter key to print some text:

{
"key": "enter",
"command": "type",
"args": { "text": "Hello There" },
"when": "editorTextFocus"
}
The type command will receive {“text”: “Hello There”} as its first argument
and add “Hello There” to the file instead of producing the default command.

Removing a Specific Key Binding Rule


You can script a key binding rule that targets the dismissal of a specific default
key binding. With keybindings.json it was always acceptable to redefine all the
key bindings of VS Code, but it can be challenging to make a small addition,
especially around overloaded keys, such as Tab or Escape. In order to hide a
specific key binding, add a - to the command and the rule will be a removal
one.

Keyboard Layout-Independent Nindings


Using scan codes, it is manageable to define keybindings that do not change
with the modification of the keyboard layout. For example: { “key”: “cmd+
[Slash]”, “command”: “editor.action.commentLine”, and “when”:
“editorTextFocus” }.
The following scan codes are accepted:

[F1]-[F19], [KeyA]-[KeyZ], [Digit0]-[Digit9]


[Backquote], [Minus], [Equal], [BracketLeft],
[BracketRight], [Backslash], [Semicolon], [Quote],
[Comma], [Period], [Slash]
[ArrowLeft], [ArrowUp], [ArrowRight], [ArrowDown],
[PageUp], [PageDown], [End], [Home]
[Tab], [Enter], [Escape], [Space], [Backspace],
[Delete]
[Pause], [CapsLock], [Insert]
[Numpad0]-[Numpad9], [NumpadMultiply], [NumpadAdd],
[NumpadComma]
[NumpadSubtract], [NumpadDecimal], [NumpadDivide]
When Clause Contexts
VS Code gives you full control over when your key bindings are activated
through the optional when clause. If some key bindings do not have a when
clause, those key binding are globally available at all times. A when clause
relates to either Boolean true or false for operating key bindings.
In addition, VS Code sets various context keys and specific values
depending on what elements are available and active in the VS Code User
Interface. For instance, the built-in Start Debugging command has the
keyboard shortcut F5, which is only enabled when there is an appropriate
debugger available (context debuggersAvailable is true) and the editor is not in
debug mode (context inDebugMode is false).

Conditional Operators
For when clause conditional expressions, the conditional operators in Table 1-
1 are used for keybindings.8
Table 1-1 Conditional operators

Operator Symbol Example


Equality == “editorLangId == typescript”
Inequality != “resourceExtname != .js”
Or || “isLinux||isWindows”
And && “textInputFocus && !editorReadonly”
Matches =~ “resourceScheme =~ /^untitled$|^file$/”

Available Contexts
You can see some of the available contexts at hand when clause contexts in the
when clause context reference. The list there is not as exhaustive, and you can
look for other when clause contexts by searching and filtering in the Keyboard
Shortcuts editor (Preferences: Open Keyboard Shortcuts) or reviewing the
Default Keybindings JSON file (Preferences: Open Default Keyboard Shortcuts
(JSON)). Tables 1-2 through 1-12 provides shortcuts for some basic
commands.9
Table 1-2 Basic editing

Command Key Command id


Cut line (empty Ctrl+X editor.action.clipboardCutAction
selection)
Command Key Command id
Copy line (empty Ctrl+C editor.action.clipboardCopyAction
selection)
Paste Ctrl+V editor.action.clipboardPasteAction
Delete Line Ctrl+Shift+K editor.action.deleteLines
Insert Line Below Ctrl+Enter editor.action.insertLineAfter
Insert Line Above Ctrl+Shift+Enter editor.action.insertLineBefore
Move Line Down Alt+Down editor.action.moveLinesDownAction
Move Line Up Alt+Up editor.action.moveLinesUpAction
Copy Line Down Shift+Alt+Down editor.action.copyLinesDownAction
Copy Line Up Shift+Alt+Up editor.action.copyLinesUpAction
Undo Ctrl+Z undo
Redo Ctrl+Y redo
Add Selection To Ctrl+D editor.action.addSelectionToNextFindMatch
Next Find Match
Move Last Selection Ctrl+K editor.action.moveSelectionToNextFindMatch
To Next Find Match
Undo last cursor Ctrl+U cursorUndo
operation
Insert cursor at end Shift+Alt+I editor.action.insertCursorAtEndOfEachLineSelected
of line
Select all Ctrl+Shift+L editor.action.selectHighlights
occurrences of
current selection
Select all Ctrl+F2 editor.action.changeAll
occurrences of
current word
Select current line Ctrl+L expandLineSelection
Insert Cursor Below Ctrl+Alt+Down editor.action.insertCursorBelow
Insert Cursor Above Ctrl+Alt+Up editor.action.insertCursorAbove
Jump to matching Ctrl+Shift+\ editor.action.jumpToBracket
bracket
Indent Line Ctrl+] editor.action.indentLines
Outdent Line Ctrl+[ editor.action.outdentLines
Command Key Command id
Go to Beginning of Home cursorHome
Line
Go to End of Line End cursorEnd
Go to End of File Ctrl+End cursorBottom
Go to Beginning of Ctrl+Home cursorTop
File
Scroll Line Down Ctrl+Down scrollLineDown
Scroll Line Up Ctrl+Up scrollLineUp
Scroll Page Down Alt+PageDown scrollPageDown
Scroll Page Up Alt+PageUp scrollPageUp
Fold (collapse) Ctrl+Shift+[ editor.fold
region
Unfold (uncollapse) Ctrl+Shift+] editor.unfold
region
Fold (collapse) all Ctrl+K Ctrl+[ editor.foldRecursively
subregions
Unfold (uncollapse) Ctrl+K Ctrl+] editor.unfoldRecursively
all subregions
Fold (collapse) all Ctrl+K Ctrl+0 editor.foldAll
regions
Unfold (uncollapse) Ctrl+K Ctrl+J editor.unfoldAll
all regions
Add Line Comment Ctrl+K Ctrl+C editor.action.addCommentLine
Remove Line Ctrl+K Ctrl+U editor.action.removeCommentLine
Comment
Toggle Line Ctrl+/ editor.action.commentLine
Comment
Toggle Block Shift+Alt+A editor.action.blockComment
Comment
Find Ctrl+F actions.find
Replace Ctrl+H editor.action.startFindReplaceAction
Find Next Enter editor.action.nextMatchFindAction
Find Previous Shift+Enter editor.action.previousMatchFindAction
Select All Alt+Enter editor.action.selectAllMatches
Occurrences of Find
Command Key Command id
Match
Toggle Find Case Alt+C toggleFindCaseSensitive
Sensitive
Toggle Find Regex Alt+R toggleFindRegex
Toggle Find Whole Alt+W toggleFindWholeWord
Word
Toggle Use of Tab Ctrl+M editor.action.toggleTabFocusMode
Key for Setting Focus
Toggle Render unassigned toggleRenderWhitespace
Whitespace
Toggle Word Wrap Alt+Z editor.action.toggleWordWrap

Table 1-3 Rich languages editing

Command Key Command id


Trigger Suggest Ctrl+Space editor.action.triggerSuggest
Trigger Parameter Hints Ctrl+Shift+Space editor.action.triggerParameterHints
Format Document Shift+Alt+F editor.action.formatDocument
Format Selection Ctrl+K Ctrl+F editor.action.formatSelection
Go to Definition F12 editor.action.revealDefinition
Show Hover Ctrl+K Ctrl+I editor.action.showHover
Peek Definition Alt+F12 editor.action.peekDefinition
Open Definition to the Ctrl+K F12 editor.action.revealDefinitionAside
Side
Quick Fix Ctrl+. editor.action.quickFix
Go to References Shift+F12 editor.action.goToReferences
Rename Symbol F2 editor.action.rename
Replace with Next Value Ctrl+Shift+. editor.action.inPlaceReplace.down
Replace with Previous Ctrl+Shift+, editor.action.inPlaceReplace.up
Value
Expand AST Selection Shift+Alt+Right editor.action.smartSelect.expand
Shrink AST Selection Shift+Alt+Left editor.action.smartSelect.shrink
Trim Trailing Whitespace Ctrl+K Ctrl+X editor.action.trimTrailingWhitespace
Change Language Mode Ctrl+K M workbench.action.editor.changeLanguageMode
Table 1-4 Navigation

Command Key Command id


Show All Ctrl+T workbench.action.showAllSymbols
Symbols
Go to Ctrl+G workbench.action.gotoLine
Line...
Go to Ctrl+P workbench.action.quickOpen
File...,
Quick
Open
Go to Ctrl+Shift+O workbench.action.gotoSymbol
Symbol...
Show Ctrl+Shift+M workbench.actions.view.problems
Problems
Go to Next F8 editor.action.marker.nextInFiles
Error or
Warning
Go to Shift+F8 editor.action.marker.prevInFiles
Previous
Error or
Warning
Show All Ctrl+Shift+P workbench.action.showCommands
Commands or F1
Navigate Ctrl+Tab workbench.action.quickOpenPreviousRecentlyUsedEditorInGroup
Editor
History
Go Back Alt+Left workbench.action.navigateBack
Go back in Alt+Left workbench.action.quickInputBack
Quick
Input
Go Alt+Right workbench.action.navigateForward
Forward

Table 1-5 Editor/window management

Command Key Command id


New Window Ctrl+Shift+N workbench.action.newWindow
Close Window Ctrl+W workbench.action.closeWindow
Close Editor Ctrl+F4 workbench.action.closeActiveEditor
Exploring the Variety of Random
Documents with Different Content
CHAPTER XIII.
SUPERNUMERARY QUEENS.
In the last chapter we were at sea without a compass by which to
steer our course aright,—with two pilots on board, 'tis true; one of
them a foreigner, experienced beyond most other men, though aged,
and infirm, and defective in his eyesight, but willing, nevertheless, nay
—anxious to conduct us to our wished-for haven; the other, though
not inexperienced, less practised, it is thought, in voyages of
discovery, and more venturesome than his senior in the office,
contending that the respectable, old gentleman had put us on a
wrong tack,—that we were in a wrong latitude,—that our reckoning
was incorrect, and even making merry with the old man's infirmities.
Perplexed, and doubting in whom it is most reasonable and safest to
confide, we seize the helm ourselves and make to the nearest shore,
and luckily land on terra firma—terra cognita, and are now
approaching a field with every corner of which we are thoroughly
acquainted. But metaphor apart, lest we should not properly sustain
it.
There is but one reigning Queen in a colony of Bees at one time:
but previously to swarming, royal-cells are constructed, and provision
made, for ensuring a successor to the Queen that leads the swarm
and emigrates, when the too-crowded population, and over-heated
temperature of the hive, render such emigration necessary. That it is
the old Queen that leaves the hive with a swarm I am well convinced,
notwithstanding what some apiarians assert to the contrary. To satisfy
myself on this point, I have sometimes in the evening of the day on
which a hive has swarmed, at other times on the second, and at
others on the third day after that event, put the parent-stock under, or
rather, I may say—over fumigation, dissected and examined the
combs and Queen-cells minutely, and the Bees also, and whenever I
did find a Queen, she was invariably a young one; but, instead of a
Queen, I have more frequently found a royal-cell just ready to give
birth, as it were, to a successor to that that had left the hive; and in
general there are several of these royal-cells containing embryo
Queens, in different states of forwardness: so that it seems, Bees
have an instinctive foresight which leads them to provide against
casualties, for they are generally provided with the means of bringing
forth supernumerary Queens, that in case the first that comes forth
should prove steril, should be defective, or in any way unfortunate, or
unfitted to assume the sovereignty of the hive, there may be others
ready to burst into being, and remedy the misfortune that would
ensue, were there but one chance of a successor, and were that one
chance to prove abortive. But no sooner is a young Queen enthroned,
as it were, and established in the government of the hive than the
supernumerary ones, in whatever stage of existence, are all
discarded, and cast out of the colony, Mr. Porter, of Cowbit, has this
year (1832) picked up eight of those discarded, virgin Queens,
together with the old Queen, which last was sorely mutilated, but not
killed—she alone was cast out alive, the others had been killed: these
nine supernumerary Queens were all cast out of one fine colony of
Bees in the course of two successive days. That colony is a
remarkably prosperous one, and has not swarmed. I myself have
observed no fewer than twenty-four supernumerary, virgin Queens
that were cast out of one of my stocks; and that stock is flourishing,
and has not swarmed: and my respected friend, Mr. Salmon, of
Stokeferry, informs me that he once collected upwards of thirty of
these young Queens; whether his stock swarmed or not I am unable
to state positively, but presume it did not; for, generally speaking,
when supernumerary, virgin Queens are cast out of a colony, it may
be considered as an indication that that colony is not only prosperous,
but that swarming is not contemplated—in fact, is abandoned for that
season. The question then is—how are Bees to be managed, in order
that they may be induced to rid themselves of these supernumeraries?
The relation of the following practical lesson will both answer the
question, and exemplify and confirm the foregoing remarks.
It has already been related (in pages 62-66) that in 1826 I forced
a colony of Bees to swarm,—that I returned that swarm to its parent-
stock, and managed so as to prevent its swarming in future,—and that
two royal nymphs were cast out on that occasion. To prove whether I
could not accomplish the same object, and prevent swarming
altogether, I had recourse to the following experiment.
On the 26th of June, 1827, at one o'clock p.m. the thermometer, in
one of my colonies of Bees, suddenly rose to 96. The progressive rise
and constantly high temperature in that colony, during the evening
and night, together with the extraordinary weight of the hive, induced
me to suspect that swarming, if not prevented, would shortly take
place. Not, however, perceiving any of the symptoms that usually
precede the immediate act of swarming, I suffered matters to go on
until the 6th of July, on which day the thermometer stood at 102. The
drones came out and sung their merry tune; and during the whole
night the temperature of the colony continued to increase. On the
next day unequivocal symptoms of swarming presented themselves.
These urged me to push my experiment to the highest pitch of proof;
I therefore went on narrowly watching and ventilating this stock, until
the 10th of July, when, in spite of my endeavours to keep down the
temperature by merely ventilating the thermometer was standing at
112, consequently I concluded that it was high time to lay this
prosperous colony under contribution; and in the evening of that day,
I took from it a beautifully finished glass of honey, as pure as the
crystal stream; its weight was sixteen pounds. I continued ventilating
the side-boxes, and placed an empty bell-glass upon the middle one,
from which I had just before taken the full one, I then withdrew the
dividing-slide, and the Bees immediately entered the glass, and began
their works in it, and in four days filled it with comb, and partly filled
the cells with honey. On the sixth day after those operations had been
performed, a continuance of the former temperature demonstrated to
me the necessity of taking away a side-box. I did so, and found its
weight to be no less than sixty-five pounds. On removing the box of
honey, I replaced it with an empty one; and on drawing up the tin-
slide, in order to admit the Bees into the empty box, to my great
gratification I found the thermometer standing at 82 in that box, and
in the space of five minutes the other collateral-box was under the
same agreeable temperature. By this continued ventilation, within the
short space of twenty-four hours afterwards, I ascertained the
following important fact,—viz.—that no sooner did the Queen-Bee feel
the agreeable change that had taken place in the interior of her
domicil, than the royal nymph was dislodged from its cell, and by the
Bees brought out of the pavilion, and laid lifeless on the front-board.
This fact taught me by experiment, that the reigning Queen would
very soon, from real necessity, have been compelled to leave the now
discarded nymph to take possession of the hive.
The Queen, owing to the excessive and daily increasing heat of the
hive, would have left her wealthy colony—would have been compelled
to leave it—had not the ventilation, and the enlargement of her
domicil, prevented the painful necessity of her so doing. This, I think,
proves the truth of the observation—that it is the old Queen which
leaves, when Bees are compelled to swarm; but, if not, the following
experimental operations have demonstrated the fact. I have united
many swarms, and every sovereign Bee I have been under the
necessity of making a captive, has invariably been an old one.
On the 25th of June, 1828, I took up a parent-stock, four days
after it had thrown off a swarm, and there found only the royal nymph
within its cradle—there was no Queen left in that stock, save the one
in embryo—the old Queen had gone with the swarm. This lesson
caused me to carry my experiments farther. Having taken up the
parent-stock, as just stated, I united all the working Bees of that stock
to those of the swarm already mentioned, and I also put the young
larvæ found in the parent-stock, to the now united-stock; I then
placed the intended royal species—the nymph already mentioned—
with the remainder of the young brood, in one of the collateral-boxes,
and immediately let the odour of the stock through the
communicating slide. To my great satisfaction I discovered the
willingness of the old Bees to bring to perfection the young they had
been compelled to leave in their former domicil. The royal nymph,
however, was an exception; she alone was instantly dragged from her
cell, and cast out of the hive.
This confirmed the proof of the important fact gained the
preceding year,—namely—that ventilation and the means of dividing
the treasures of the Bees, by taking off a glass or a box of honey,—or,
if necessary, by taking off both a glass and a box, set aside the
necessity for swarming. On all occasions, under this practice, a proper
temperature may be supported in a colony; and in all critical points,
by a just observation of the state of the thermometer, Bees may be
relieved and assisted, and all the mischiefs attending the old mode of
management may be guarded against and prevented. For when
adequately relieved and properly assisted, they proceed to rid the
colony of all embryo Queens, which would only become so many
supernumeraries in a hive where the reigning Queen is fertile, and the
necessity for emigration is superseded. But, unless Bees could be
made to understand that accommodation will be extended to them at
the proper time, they, guided by their sense of their situation—not by
ours—naturally and wisely provide their own means of relieving
themselves; and in so doing frequently bring forth what afterwards
become supernumerary Queens, which are invariably destroyed and
cast out of the colony, as soon as the Bees are sensible that they have
no occasion for them. And, whenever a royal nymph or a virgin Queen
is thus cast out, swarming need not be apprehended.
CHAPTER XIV.
BEE-FEEDING.
Neglected generally, as is the management of Bees by their cottage
possessors, there is no part of it less attended to, nor more slovenly
performed, when performed at all, than that of feeding. The cottager
commonly takes up, as he terms it, his best hives for the sake of the
treasures they contain, or are supposed to contain. This is destroying
Bees because they are rich! He also takes up the lightest and poorest
—of course the late swarms—and those that are the least likely to live
through the winter; because if he get from one of these but two or
three pounds of honey, though he seldom gets so much, and a few
ounces of wax, he thinks that that is all clear gain: and, if he get
neither honey nor wax, he, at any rate, gets rid of the expense and
trouble of feeding his good-for-nothing swarms, which, in his opinion,
however fed, would never come to any good. A pennyworth of
brimstone will do the job at once, and is more easily paid for than a
pound of sugar, and after that another, and perhaps another. Such is
the reasoning, and calculation, and cruel practice of the generality of
cottage Bee-keepers! Such is the destruction annually dealt out to
hundreds of poor swarms, and thousands and millions of poor Bees!! I
do from my heart pity and deplore the untimely fate of these
suffocated, innocent, valuable insects. To destroy Bees because they
are rich is a barbarous practice, and ought by all means to be
discountenanced and discontinued;—to destroy Bees because they are
poor and may need support, is cruel—-is inhuman—is shocking,
however little may be thought of it by those who still adhere to this
practice. Even with the common straw-hives, this terrible havoc
among poor stocks and late swarms might be prevented, if they, who
happen to have them, would so far improve themselves in the
practical management of an apiary, as to be able to fumigate, and to
take such Bees out of the hives containing them, and to join them to
their richer stock-hives, in the latter end of August, or any time in
September. This is by far the best plan that can be adopted with poor
hives; and there really is no difficulty in the operation. This
strengthens the population of rich stocks, and causes them to swarm
early in the ensuing spring, it preserves the Bees, which is of itself,
independently of the advantages accruing from it afterwards, a
consideration that never should be lost sight of,—it leaves the
contents of the fumigated hive, as absolutely in the possession of the
Bee-owner, as if the Bees had been suffocated and destroyed,—and in
most cases it entirely does away with the necessity of feeding. I
confess I should rejoice greatly, and flatter myself that every friend of
humanity would rejoice with me, to see this mode of disposing of
weak hives universally adopted; because, it may be presumed, that
the next step in the way of improvement would be to take away the
superabundant treasure of the Bees and still preserve them.
Notwithstanding, under certain circumstances it will always be
necessary, and judicious in Bee-masters, to have recourse to feeding.
If, for instance, after an early swarm is put into a hive, or into a box,
two or three or more cold, ungenial days should follow, and more
particularly if those days should happen to be rainy also, by feeding
such a swarm you will assist your impoverished labourers, not only
with necessary food, but with materials and treasure, which,
unfortunately for them, they cannot at such an unfavourable juncture
get abroad to collect elsewhere.
Different apiarians have adopted and recommended different ways
of feeding Bees, none of which, in my opinion, possess any great
merit; in order, therefore, to improve this part of Bee-management,
my endeavours have been directed to the contrivance and
construction of a feeding department; which is attached to my
collateral-hives in so convenient a manner, that I can feed my Bees, at
any time when feeding is required—in spring, in autumn, or in winter,
without disturbing the position of the hive, and without changing its
interior temperature; which temperature cannot be kept equable and
comfortable, where a hive is frequently lifted up from its stand, and its
interior is suddenly exposed to the action of perhaps an extremely
cold atmosphere. Besides, a hive cannot be lifted up without breaking
the propolis by which it has been cemented all round and made fast to
its stool. In sharp, cold weather, disruption of the hive from its stool is
a serious mischief done to the Bees; because, however carefully it
maybe set down again, there will have been made many vents and
crevices between the edge of the hive and the stool, which will
occasion various currents of air, cold, frosty, or other—proper or
improper—to be continually passing through the lower part of the
hive. And should Bees be tempted by food, or urged by hunger, to
descend into these currents in sharp, frosty weather, but few of them
will get away alive; the keen air acting upon them whilst feeding,
paralyzes and kills them. I am an advocate for keeping Bees cool in
winter—yes, cool and still also: let them not be disturbed nor
disunited,—let them not be forced nor tempted to (if I may so say)
uncluster themselves. I have no objection to a current of air passing
through the lower part of a hive in winter, provided the Bees be not
disturbed—be not exposed singly to its nipping influence; but I
strongly object to the feeding of Bees in such currents, because, in
that case, feeding is prejudicial to them. The cottager seldom protects
his hives in winter with any other covering than that which a pot,
called a pancheon, whelmed over each hive, forms; capped with this
unsightly piece of earthenware, his hives are exposed to all weathers;
consequently the less he disturbs them the better. He therefore should
give his weak stocks a copious feeding, in September at the latest,—
not molest them during the severity of winter,—but in the spring, as
soon as the Bees begin to make their appearance at the mouth of his
hives, introduce his wooden trough furnished with a little Bee-sirup,
and then close up the entrance,—withdraw the trough in the morning,
and return it replenished every evening, as long as feeding is
necessary. Tearing off a hive at Christmas, and scattering a few
ounces of brown sugar upon the stand, and then setting down the
hive again, deserves not the name of feeding; though it is all the
bounty that is bestowed on some stocks; and is even more than
others are treated with. It need not then be wondered at that so
many stocks of Bees perish in the winter, and in the spring of every
year. By judicious feeding, at proper seasons, almost any stock of
Bees may be preserved: by injudicious feeding, at an improper
season, even good stocks—stocks that would survive, if not fed at all,
nor molested, during the depth and severity of winter, may be
seriously injured—may be totally destroyed. The peasant Bee-keeper,
however, does not often subject himself to the charge complimental of
being accessary to the death of his Bees through mistaken kindness.
The sum and substance of my directions, as respects Bee-feeding,
are these:—
1. In spring feed sparingly.
2. In autumn feed plentifully.
3. In winter do not feed at all.
4. Feed swarms, if unseasonable weather immediately follow the
act of swarming.
5. Preserve the Bees of weak stocks, and prevent a great deal of
the necessity for feeding, by adding them to those that are rich and
able to support them. This last is the best and cheapest, nay—it is
even a profitable method of feeding Bees.
Early swarming, where swarming is necessary as in the straw-hive
colonies, is of great advantage to the watchful apiarian, but not to the
inattentive and slothful manager. I have seen in a cottager's garden a
swarm of Bees on the 10th of May, which was considerably weaker in
the month of August, than was a swarm on the 10th of July, and that
solely on account of not being fed and properly attended to.
If early swarms are judiciously fed, and supported by a natural
heat within, they will be greatly benefitted thereby, and eventually
prosper.
But, notwithstanding what has been already said, the cottager may
probably ask—"how can I feed my Bees without lifting up their hive?"
I again and again request him to examine my collateral box-hive; and
he will perceive that he may easily feed the Bees in his cottage-hive in
the same easy manner, if he have but ingenuity enough to attach a
proper feeder to the stool or floor of his hive.
Mr. Huish advises apiarians to make choice of a fine and warm day
in which to feed Bees, he says, the danger to be apprehended from
the change of the temperature in the hive will thereby be obviated.
This, I grant, is rational and humane, and in some degree a
confirmation of my already expressed opinion, respecting the
mischiefs resulting from the inconsiderate practice of exposing the
interior of a hive to sudden and extreme alternations of temperature.
But it matters not what sort of weather it may be, if my mode of
feeding be adopted. I feed my Bees in their native temperature,
without disturbing them or exposing their food to the temptation of
robbers, which feeding in the ordinary way so frequently encourages,
during the spring and autumnal seasons; and it is at these times that
Bees stand in most need of assistance.
In the year 1828, I purchased a cottage-hive of a neighbour, it was
a large hive, and well-stocked with Bees, but extremely light; I was
fearful for the safety of its inmates, and, therefore, placed it over one
of my feeders; in order to give them support by feeding, I placed the
sirup intended for their food beneath the hive; but to my great
surprise the Bees refused to take the proffered bounty. I persevered in
my endeavours to induce them to feed for four days, but they would
not touch the well-intended boon: I therefore resolved to ascertain
the cause of their refusal, and on turning up the hive I discovered that
thousands of the Bees were in a dying state, I had the curiosity to
take the whole of them out singly. After several hours' particular
attention and patient search, I found the Queen was dead. I then
united the weak, enfeebled Bees to a rich stock, and they nearly all
recovered their strength. Their numbers greatly assisted in the labour
of the hive to which they were joined. Certain it is, that if any accident
befal their Queen in winter, it is total ruin to that stock of Bees: where
such a death is discovered, feeding will avail nothing, the Bees
dwindle away and perish.
Mr. Huish says—and he is perfectly correct in saying—that there
are some persons who defer the feeding of their Bees until the
moment they suppose that they may be in actual want. This is a most
reprehensible plan; for should feeding be too long delayed, the Bees
will become so weak and debilitated, that they will be unable to
convey the food into their cells: the food ought to be administered to
poor stocks, three weeks or a month before they may be supposed to
be in actual want; it will then be conveyed with the greatest despatch
into the cells, and the hive will be saved from a death of famine. He
then goes on to observe—that some apiarians conceive that the
feeding of Bees in the spring renders them lazy and inactive. On what
this opinion is grounded he is at a loss to conjecture, as must be
every practical apiarian; for it is in direct contradiction, not only to Mr.
Huish's experience, but also to that of many other apiarians. A little
food granted to a populous, and even well-provisioned box or hive in
the spring, is attended with very beneficial consequences. It diffuses
animation and vigour throughout the whole community;—it
accelerates the breeding of the Queen—and consequently conduces to
the production of early swarms, where room is not previously given in
order to prevent swarming altogether.

BEE-FOOD.
Artificial food proper for Bees may be made by mixing coarse, raw
sugar, and good, sound ale, in the following proportions:—
To a quart of ale add a pound and a half of sugar, gently boil them,
in a sweet, well-tinned saucepan, over a fire clear from smoke, for five
or six minutes, or until the sugar be dissolved and thoroughly
incorporated with the ale; and, during the process of boiling, skim off
the dross that rises to the surface. Some persons boil these
ingredients much longer, and until they become, when cool, a thick,
clammy sirup; this not only diminishes the quantity of the mixture, but
renders it rather disadvantageous, to weak Bees in particular, by
clogging and plaguing them, if, as they are almost sure to do, they get
their legs or wings daubed with it. I prefer sirup in a more liquid state.
For spring feeding, I advise—that not more than a pound of sugar
be put to a quart of ale, or sweet wort, if it can be obtained, and that
a small quantity of common salt be added. By a small quantity I mean
—a drachm or two at the most to a quart of the sirup. Salt, it has
been said, is conducive to the health of Bees, and the most efficacious
remedy for the dysentery, which sometimes affects Bees in the spring;
therefore, it may not be amiss to put a little salt into their food, by
way of preventive, rather than to have recourse to it afterwards as a
remedy.
Speaking of the substances which are proper for the feeding of
Bees, Mr. Huish says[I]—"he is perfectly convinced that honey alone is
very injurious to Bees, as it in general gives them the dysentery."
Whether by this extraordinary passage Mr. Huish has, or has not,
subjected himself to the lash of his own ridicule, it would be
hypercritical and unbecoming in me to determine. As an apiarian I
respect him; in no other character am I acquainted with him. His work
on the management of Bees I have read, and have derived
information and occasionally assistance from some of its pages. There
are in it, nevertheless, several untenable positions, of which I consider
the above-quoted passage to be one: and, if what he has remarked
somewhat sarcastically, in a note at the foot of page 31, be read in
conjunction with this passage, it will be for the candid reader, apiarian,
or other, to decide whether Mr. Huish in propriâ personâ does not,
oddly enough, exemplify his own remark. It is there said—that "there
is no wonder in nature which an apiarian has not seen." Professedly
an apiarian himself, he must have seen some, at least, of the wonders
in nature, otherwise he never could have been "perfectly convinced"—
that honey—"honey alone"—the very substance which Bees, guided
by the instinct of their nature, collect with so much industry, and store
up with so much care, for their subsistence, should be "very injurious
to them, and in general give them the dysentery." From this it seems
that the substance, which is the natural food for one stock of Bees, is
physic for another, if not poison!! I cannot but express my
astonishment that a gentleman, so acute and experienced as Mr.
Huish undoubtedly is, should have asserted in the most unqualified
manner—that "honey alone is very injurious to Bees." Were this the
fact, rich stocks, and all stocks that subsist upon "honey alone" during
winter, would "in general" be affected with dysentery in the spring,
which certainly is not the case. "In general" rich stocks are healthy
and strong in the spring. Poverty is the predisposing cause of
dysentery among Bees: a regular supply of their natural—their
peculiar food, does not induce dysentery or disease of any sort. Had
Mr. Huish analyzed the honey given to Bees as food, and which
induced dysentery, he would, I suspect, have discovered that it was
not "honey alone," but—medicated honey—honey and brimstone, or
honey strongly tinctured either with brimstone or tobacco. That honey,
tinctured with the pernicious qualities of those substances, should
have a laxative effect upon impoverished, debilitated Bees, is no more
than might be expected: but then it is not the honey that has the
"injurious" effect, but the essence of the brimstone or of the tobacco
that is administered along with it. What effect honey, that has not
been stoved and saturated with brimstone or with tobacco, may have
upon weak Bees, when given to them for spring food, I pretend not to
determine, because I have never tried the experiment. But I do say
that before the arrival of spring, honey, that has been drained or
expressed from the comb, undergoes fermentation, and that
fermentation may, for aught I know, impart to it physical properties,
which in its pure, liquid, unchanged state, in the warm hive, it does
not possess. I am not chemist enough to venture to assert that it is
so, but I think it highly probable that fermentation may alter the
properties of honey, and perhaps may render it unwholesome to Bees.
But fresh, unfermented honey, even that in the blackest and oldest
combs—the very refuse, and all such as the cottage-housewife makes
into common mead, if spread upon large dishes and placed in an
apiary, will be banqueted upon by the Bees in the most eager manner,
and is apparently much enjoyed by them. They soon carry into their
hives what they do not consume on the spot, and suffer no
inconvenience whatever from the treat. I have feasted my Bees in this
way scores of times, and esteem it the very best mode of autumnal
feeding, and the most profitable way of disposing of broken combs
and refuse honey. "Honey alone" is the natural food of Bees, and if
given to them pure and untainted, in its primitive, limpid state, so far
from being injurious, it is highly beneficial to them; of this I have not
the shadow of a doubt. For autumnal feeding, I prefer honey to all
other substances, and recommend it as the most proper food that can
be given to them.
[I] Huish on Bees, page 272.
CHAPTER XV.
CATALOGUE OF BEE-FLOWERS, &c.
From the account of the mode of supplying Bees with artificial food, to
the enumeration of such trees, plants, and flowers as are most
frequented by Bees, for the purpose of culling from them the various
substances, which their necessities, their nature, or their instinct
(which is a part of their nature) urge them to seek for, the transition is
so easy and natural—is so akin to the subject of Bee-feeding, as to be
rather a continuation thereof than a transition to a fresh one; I
therefore proceed to give a catalogue of those trees and plants which
afford pabulum for Bees. It is furnished principally from my own
ocular observation, and is partly collected from the observation of
others, whose curiosity has led them to pay attention to the subject,
and to make remarks upon it.

Alder-tree Celery
Almond-tree Cherry-tree
Althea frutex Chesnut-tree
Alyssum Chickweed
Amaranthus Clover
Apple-tree Cole or coleseed
Apricot-tree Coltsfoot
Arbutus (alpine) Coriander
Ash-tree Crocus
Asparagus Crowfoot
Aspin Crown-imperial
Cucumber
Balm Currants
Bean Cypress-tree
Beech-tree
Betony Daffodil
Blackberry Dandelion
Black-currant-tree Dogberry-tree
Borage
Box-tree Elder-tree
Bramble Elm-tree
Broom Endive
Bugloss (viper's)
Buckwheat Fennel
Burnet Furze

Cabbage Goldenrod
Cauliflower Gooseberry-tree
Gourd

Hawthorn Marigold (French)


Hazel-tree Marigold (single)
Heath Maple-tree
Holly Marjoram (sweet)
Holly-hock (trumpet) Melilot
Honey-suckle Melon-tree
Honey-wort (cerinthe) Mezereon
Hyacinth Mignionette
Hysop Mustard

Ivy Nasturtium
Nectarine-tree
Jonquil Nettle (white)

Kidney-bean Oak-tree
Onion
Laurel Orange-tree
Laurustinus Ozier
Lavender
Leek Parsley
Lemon-tree Parsnip
Lily (water) Pea
Lily (white) Peach-tree
Lime-tree Pear-tree
Liquidamber Peppermint
Liriodendrum, or Tulip-tree Plane-tree
Lucerne Plum-tree
Poplar-tree
Mallow (marsh)

Poppy Tacamahac
Primrose Tansy (wild)
Privet Tare
Teasel
Radish Thistle (common)
Ragweed Thistle (sow)
Rasberry Thyme (lemon)
Rosemary (wild) Thyme (wild)
Roses (single) Trefoil
Rudbechiæ Turnip

Saffron Vetch
Sage
Saintfoin Violet (single)
St. John's wort
Savory (winter) Wallflower (single)
Snowdrop Willow-herb
Snowberry-tree Willow-tree
Stock (single) Woad
Strawberry
Sunflower Yellow weasel-snout
Sycamore-tree

Of these some are valuable for the supply of pabulum they afford
Bees early in spring; as the white alyssum, broom, crocus, furze,
hazel, laurustinus, mezereon, ozier, plane-tree, poplar-tree, snowdrop,
sycamore-tree, the willow-tree, &c. Others again are valuable on
account of the lateness of the season that Bees derive assistance from
them; as the golden-rod, heath, ivy, laurustinus, mignionette,
ragweed, &c. Some abound with honey; as borage, buckwheat,
burnet, coleseed, currant and gooseberry-trees, heath, leek,
mignionette, mustard, onion, thyme, the blossoms of apple, apricot,
cherry, nectarine, pear, and plum-trees, and the leaves of those trees
remarkable for what is called honey-dew, as the aspin, blackberry,
laurel, laurustinus, lime, maple, oak, plane, poplar, and sycamore-tree.
Among those that are rich in pollen, may be classed—the arbutus,
ash, blackberry, box, chesnut, cypress, elder, laurel, marsh-mallow,
turnip, &c.
The cultivation of some of the most valuable of these is too-limited
to be particularly advantageous to Bees, as alyssum, borage, burnet,
golden-rod, laurustinus, mezereon, mignionette, &c. The most
extensive and lasting Bee-pasturage in this country is clover, heath,
and in my own immediate neighbourhood mustard. In short, every
one of the flowers, &c. mentioned in the foregoing catalogue, and
others innumerable, are in their turns resorted to by Bees, and of
course are more or less advantageous to them.
CHAPTER XVI.
HONEY-COMB.
To excite our admiration of the industry and ingenuity of Bees, we
need only take into our hands a piece of honey-comb, and examine it
attentively. Its neatness, its beauty, its construction, the similarity and
exact proportion of its double web of cells, for a honey-comb is, in
fact, a web of cell-work on both sides, are most admirable, and
calculated to lead the contemplative mind from nature's work up to
nature's God.
When a swarm of Bees is put into a hive, or into a box, they
immediately set about constructing combs in it, and proceed in their
building work with a rapidity that is truly astonishing. The cells that
are opposite to each other are advanced alike: the work on one side is
just as forward and in the same state as that on the other side. In the
cells first finished the Queen begins to deposit her eggs. In an
incredibly short space of time, an immense number of cells is
completed, and the Bees store pollen, farina, or Bee-bread, (which are
so many names for the same substance) in some of those not already
occupied by eggs, and in others honey soon becomes visible: all is
activity, industry, and apparently happiness. But, to come to
particulars:—
As Dr. Bevan, in the course of his masterly chapter "on the
Architecture of Bees," has given an engraved representation of a piece
of honey-comb,—and as Mr. Huish also has given a somewhat similar
representation, but better than Dr. Bevan's, inasmuch as it is more
varied, and shows the royal-cells in their different stages to more
advantage, and the drone-cells likewise;—I cannot, perhaps, do the
honey-comb so much justice in any way, as by presenting to my
reader a copy of Mr. Huish's piece of comb, which has been greatly
improved by the skilful hand of my engraver, and by giving along with
it Dr. Bevan's able description. Though after all, a piece of real comb,
to look at and examine, is more beautiful and far better than any
engraving possibly can be, however cleverly it may be executed: and
therefore, notwithstanding the plate, I would recommend it to my
reader to procure a piece of real honey-comb, and with it in his hand
read the following account, which is chiefly from Dr. Bevan's pen.
Royal-cells in different states of forwardness, common-cells, and
drone-cells, are intended to be severally represented in this plate.
The ranges forming the upper half, and marked—a. are intended to
represent common brood-cells and honey-cells—most of them in an
empty state. The lower ranges, marked—b. are drone-cells, and are
represented as closed up, and as they appear when full of brood.
Drone-cells, when filled with brood and sealed up, present a fuller
and more convex surface than the cells containing common brood—
these, that is—the cells containing the brood that becomes working
Bees, are sometimes flat and even, and sometimes rather concave.
The four large cells, attached perpendicularly to the edge of the
comb, and marked—c. d. e. f. are royal-cells in different states of
forwardness; that marked—c. is similar in size and shape to an
acorn-cup, and is supposed to be quite empty; that marked—d. is in
a more advanced state, and is supposed to contain a royal embryo,
in its larva state: the royal-cell, marked—e. is considerably
lengthened, narrowed, and nearly closed, because the larva it is
supposed to contain is about to be transformed into a royal nymph,
in which stage of its existence, as it does not require the assistance
of nurses or common Bees, it is closed up entirely, as in the royal-
cell, marked—f. In this closed cell it progresses from nymph to Bee,
and in due time—that is, in about sixteen days from its being
deposited as an egg, it emerges a virgin Queen. When the
temperature of a hive, or pavilion of nature, is at a proper height—
namely, between 70 and 80 degrees, sixteen days is the period
nature requires for the production of a Queen-Bee,—twenty-one for
the perfection of a working Bee,—and twenty-six for a drone Bee.
But, as Dr. Bevan very justly remarks, "the development of each
species proceeds more slowly when the colonies are weak, or the air
cool,—and that when the weather is very cold it is entirely
suspended."
But to return from this short, though it is hoped, not
uninteresting digression, into which the explanation of the Queen-
cells has led us.
"The combs of the Bee-hive comprise a congeries of hexagonal
cells, formed by the Bees, as receptacles for honey or for embryo
Bees. A honey-comb is allowed to be one of the most striking
achievements of insect industry, and an admirable specimen of
insect architecture. It has attracted the admiration of the
contemplative philosopher in all ages, and awakened speculation,
not only in the naturalist, but also in the mathematician: so regular,
so perfect, is the structure of the cells, that it satisfies every
condition of a refined problem in geometry. Still a review of their
proceedings will lead to the conclusion, as Huber has observed, that,
"the geometrical relations, which apparently embellish the
productions of Bees, are rather the necessary result of their mode of
proceeding, than the principle by which their labour is guided." "We
must therefore conclude, that Bees, although they act geometrically,
understand neither the rules nor the principles of the arts which they
practise so skilfully, and that the geometry is not in the Bee, but in
the great Geometrician who made the Bee, and made all things in
number, weight, and measure.
"Before the time of Huber, no naturalist had seen the
commencement of the comb, nor traced the several steps of its
progress. After many attempts, he at length succeeded in attaining
the desired object; by preventing the Bees from forming their usual
impenetrable curtain by suspending themselves from the top of the
hive; in short, he obliged them to build upwards, and was thereby
enabled, by means of a glass window, to watch every variation and
progressive step in the construction of a comb.
"Each comb in a hive is composed of two ranges of cells, backed
against each other: these cells, looking at them as a whole, may be
said to have one common base, though no one cell is opposed
directly to another. This base or partition, between the double row of
cells, is so disposed as to form a pyramidal cavity at the bottom of
each, as will be explained presently. The mouths of the cells, thus
ranged on each side of a comb, open into two parallel streets (there
being a continued series of combs in every well filled hive). These
streets are sufficiently contracted, to avoid waste of room, and to
preserve a proper warmth, yet wide enough to allow the passage of
two Bees abreast. Apertures through different parts of the combs
are reserved to form near roads, for crossing from street to street,
whereby much time is saved to the Bees.

These in firm phalanx ply their twinkling feet,


Stretch out the ductile mass, and form the street,
With many a cross-way path and postern gate,
That shorten to their range the spreading state.

Evans.
"Bees, as has been already observed, build their cells of an
hexangular form, having six equal sides, with the exception of the
first or uppermost row, the shape of which is an irregular pentagon,
the roof of the hive forming one of the members of the pentagon.
"There are only three possible figures of the cells," says Dr. Reid,
"which can make them all equal and similar, without any useless
interstices. These are—the equilateral triangle, the square and the
regular hexagon. It is well-known to mathematicians, that there is
not a fourth way possible, in which a plane may be cut into little
spaces, that shall be equal, similar, and regular, without having any
interstices." Of these three geometrical figures, the hexagon most
completely unites the prime requisites for insect architecture. The
truth of this proposition was perceived by Pappus, an eminent Greek
philosopher and mathematician, who lived at Alexandria, in the reign
of Theodosius the Great, and its adoption by Bees, in the
construction of honey-comb, was noticed by that ancient
geometrician. These requisites are:—
"First, Œconomy of materials. There are no useless partitions in a
honey-comb, each of the six lateral panels of one cell forms also one
of the panels of an adjoining cell; and of the three rhombs which
form the pyramidal base of a cell, each contributes one third towards
the formation of the bases of three opposing cells, the bottom or
centre of every cell resting against the point of union of the panels
that are at the back of it.
"Secondly, Œconomy of room; no interstices being left between
adjoining cells.
"Thirdly, the greatest possible capacity or internal space,
consistent with the two former desiderata.
"Fourthly, Œconomy of materials and economy of room produce
economy of labour. And in addition to these advantages, the cells are
constructed in the strongest manner possible, considering the
quantity of materials employed. Both the sides and bases are so
exquisitely thin, that three or four placed on each other are not
thicker than a leaf of common writing paper; each cell, separately
weak, is strengthened by its coincidence with other cells, and the
entrance is fortified with an additional ledge or border of wax, to
prevent its bursting from the struggles of the Bee-nymph, or from
the ingress and egress of the labourers. This entrance border is at
least three times as thick as the sides of the cell, and thicker at the
angles than elsewhere, which prevents the mouth of the cell from
being regularly hexagonal, though the interior is perfectly so.

On books deep poring, ye pale sons of toil,


Who waste in studious trance the midnight oil,
Say, can you emulate with all your rules,
Drawn, or from Grecian or from Gothic schools,
This artless frame? Instinct her simple guide,
A heaven-taught insect baffles all your pride.
Not all your marshall'd orbs that ride so high,
Proclaim more loud a present Deity,
Than the nice symmetry of these small cells,
Where on each angle genuine science dwells,
And joys to mark, through wide creation's reign,
How close the lessening links of her continued chain.

Evans.
"Having just adverted to the ingenuity of Bees in thickening, and
thereby strengthening the mouths of the cells, it may here be
observed—that additional strength is also derived from the Bees
covering the whole surface of the combs, but more particularly the
edge of the cells, with a peculiar kind of varnish, which they collect
for the purpose. At first the combs are delicately white, semi-
transparent, and exceedingly fragile, smooth but unpolished: in a
short time their surfaces become stronger, and assume more or less
of a yellow tint. The deepening of the colour of honey-combs has
been supposed, by some, to be the effect of age; and in part it may
be: but it is principally owing to the coat of varnish, with which the
Bees cover them. This varnish strongly resembles propolis,
appearing to differ from it only in containing the colouring material
which imparts to wax its yellow hue. The source of this colouring
matter has not been discovered: it is insoluble in alcohol, but the
manufacture of white-wax shows that it is destructible by light. But
to return to the construction of the cell-work.
"The pyramidal basis of a cell is formed by the junction of three
rhomboidal or lozenge-shaped portions of wax: the apex of the
pyramid being situated where the three obtuse angles of the
lozenges meet. To the exterior edges and angles are attached the six
panels or sides of each cell. The apex of each pyramidal bottom, on
one side of a comb, forms the angles of the bases of three cells on
the opposite side, the three lozenges respectively concurring in the
formation of the bases of the same cells. This will, I hope, explain
what is meant by "each cell separately weak, being strengthened by
coincidence with others." The bottom of each cell rests upon three
partitions of opposite cells, from which it receives a great accession
of strength.
"As it is desirable that the reader should thoroughly comprehend
this subject, I will re-state it in other words. The partition which
separates the two opposing rows of cells, and which occupies, of
course, the middle distance between their two surfaces, is not a
plane but a collection of rhombs, there being three at the bottom of
each cell: the three together form in shape, a flattened pyramid, the
basis of which is turned towards the mouth of the cell; each cell is in
form, therefore, a hexagonal prism, terminated by a flattened
trihedral pyramid, the three sides of which pyramid are rhombs, that
meet at the apex by their obtuse angles.
"The union of the lozenges in one point, in addition to the
support which it is the means of affording to the three partitions
between opposing cells, is also admirably adapted to receive the
little egg and to concentrate the heat necessary for its incubation.
"Each obtuse angle of the lozenges or rhombs forms an angle of
about 110 degrees, and each acute one, an angle of about 70
degrees. Mr. Maraldi found by mensuration that the angles of these
rhombs, which compose the base of a cell, amounted to 109
degrees and 28 seconds, and 70 degrees and 32 seconds: and the

You might also like