Working with Files and Folders
Being the powerful editor it is, Visual Studio Code provides a convenient way of working with code files and folders containing both loose files and projects. In this chapter you will learn how to work with individual files, with folders containing source
- PDF / 696,817 Bytes
- 17 Pages / 439.37 x 666.142 pts Page_size
- 45 Downloads / 211 Views
Working with Files and Folders Being the powerful editor it is, Visual Studio Code provides a convenient way of working with code files and folders containing both loose files and projects. In this chapter you will learn how to work with individual files, with folders containing source code files, and with workspaces. You will also learn about VS Code’s independency from proprietary project systems as well as the built-in support for a few, popular project types.
Visual Studio Code and Project Systems Visual Studio Code is file and folder based. This means that you can open one or more code files distinctly, but it also means that you can open a folder that contains source code files and treat them in a structured, organized way. When you open a folder, Visual Studio Code searches for one of the following files: •
Tsconfig.json
•
Jsconfig.json
•
Package.json
•
Project.json
•
.sln Visual Studio solutions for .NET Core with the C# extension installed
© Alessandro Del Sole 2019 A. Del Sole, Visual Studio Code Distilled, https://doi.org/10.1007/978-1-4842-4224-7_4
77
Chapter 4
Working with Files and Folders
If Code finds one of these files, it is able to organize the file structure into a convenient editing experience and can offer additional rich editing features such as IntelliSense and code refactoring. If a folder only contains source code files, without any of the aforementioned .json or .sln files, it still opens and shows all the source code files in that folder, providing a convenient way to switch between all of them. This chapter describes how to work with individual files and with folders in Visual Studio Code, and more details about how it manages projects will be provided in the subsection “Working with Folders and Projects.”
Working with Individual Files The easiest way to get started editing with Visual Studio Code is working with one code file. You can open an existing supported code file with File ➤ Open (Ctrl+O or ⌘+O on macOS). Visual Studio Code automatically detects the language for the code files and enables the proper editing features. Of course, you can certainly open more files and easily switch between files by pressing Ctrl+Tab (or ^+Tab on macOS). As you can see in Figure 4-1, a convenient popup will show the list of open files; by pressing Ctrl+Tab, you will be able to browse files, and when you release the keys, the selected file will become the active editing window.
Figure 4-1. Quickly navigating between open editors
78
Chapter 4
Working with Files and Folders
Simply close an editor by using the Close button at the upper right corner, or use the Close All Files command in the File menu.
Note In the Visual Studio Code terminology, it is common to refer to open files as active editors or open editors. This is because editor windows are not limited to code files, but they can also display documentation files or provide formatted previews of the content of other types of files (e.g., images and spreadsheets).
Creating Files You have several ways to create a
Data Loading...