We will write and save our code in a text editor. As the name implies, it's a piece of software meant to edit text.
Word processing programs like Microsoft Word and Google Docs may be the first thing that comes to mind when you think of "text editors." However, these programs are not ideal for writing code because they add styles and formatting that get in the way of code. We want plain, raw text without any extras like fonts, paragraph indentation, and so on.
If you have a Mac, your device comes with a text editor called TextEdit, which can be found in your Applications list. If you have a PC, the default text editor is Notepad, which can be found through the Start menu. The Mac Terminal application also includes a console-based text editor called Nano. These text editors allow us to write code with plain, raw text.
At Epicodus, we use a free text editor called Visual Studio Code. Visual Studio Code, also known as VS Code, was designed with web developers and computer programmers in mind. It includes many useful features that help write and navigate code more efficiently.
To install Visual Studio Code on your device, download the appropriate installer for your operating system at the Visual Studio Code website.
If you are on a Mac, make sure that after you download VS Code that you drag the application "Visual Studio Code.app" to the Applications folder. Doing so makes it available in the macOS Launchpad and you can more easily configure your terminal to use the
code keyword to open projects in VS Code from the command line (there is more on this topic below).
Extended Mac installation and set up instructions can be found on the VS Code documentation for Mac.
If you are using a PC with Windows, you will work through a series of prompts from the installer:
Extended Windows installation and set up instructions can be found on the VS Code documentation for Windows.
Let's take a quick tour of Visual Studio Code. When we open the editor, VS Code will open a "Welcome" page that offers options such as "New file," "Open folder..." and so on. We will usually be creating new files and opening folders through the command line.
For now, click on "New file." This will open a blank screen where we can type. If we add content to the file, we see the
x at the top becomes a black circle. Go to the "File" menu and click "Save As." This tells us there is content that hasn't yet been saved. We'll save this file as
my-first-webpage.html using the
.html extension to indicate that this will be a document written in HTML. The black circle returns to a grey
x and we know that our file's content has been saved.
Visual Studio Code offers developers the ability to customize the editor's settings and shortcuts. We can access the Settings view on a Mac by holding down the Command key (
cmd), pressing the comma key (
,), then releasing both. On a Windows machine we can hold down the control key (
ctrl), press down the Windows key, then release both. For the keyboards at Epicodus, you will likely have to press
Sometimes you'll see instructions that include multiple keys separated by a plus sign like this:
,. When you see this it means you should hold down the first key, press the key(s) that come next, then release them all at the same time, like we did above.
One setting that we want to make sure we have in place is the tab length. Writing good code means making a habit of using consistent indentation. Scroll down to "Editor: Tab Size" in the settings and confirm that the indentation is set for 2 spaces. This way, we can use the tab key for indentation instead of hitting the space bar twice.
We'll also want to configure our machine so that we can run the
code command in the terminal's command line. This allows us to open up all the files in a project with the command
code . (The
. means "all" - so this command is instructing VS Code to open a project's files.)
To set this up on a Mac machine, we need to do the following:
This will automatically install the
code command so we can use it in the terminal. Note that in the image above it says "recently used" - this will only show up on your machine if you installed the
code command recently.
If you are a Windows user, this is already taken care of because we made sure "Add to PATH" was clicked when we installed VS Code.
There are many things you can do to customize VS Code on your own machine, including adding keyboard shortcuts, themes, and packages that add other functionality to the editor. We won't cover that in this lesson - however, we encourage you to explore this further on your own throughout the course.
You should also install the following extensions:
These extensions allow us to collaborate remotely with our pairs. All students learn remote collaboration tools, and online students will use these tools every class session. We go into detail about how to use these extensions in the lesson Installing and Using Live Share. You'll also get practice with these tools in the very first week of class.
For more details about using Visual Studio Code, take a look at the Visual Studio documentation.
Text editor: Software designed to write text in a raw format without formatting or styling added.
TextEdit: The default text editor that comes on a Mac device; available in Applications.
Notepad: The default text editor that comes on a Windows device; available through the Start menu.
Nano: A console-based text editor that comes as part of the Mac Terminal application.
Visual Studio Code: Free open source text editor created for developers writing code.
Package manager: Software that is designed to help manage other programs that are installed or need to be installed on a device.
Lesson 3 of 11
Last updated May 18, 2022