AI Learning Hub › Learn AI › Self-Paced Courses › VS Code: Files, Changes, and AI Agents › Open a Folder, Not a File

Module 2 ยท Beginner

Open a Folder, Not a File

A file, a folder, a VS Code workspace and a Git repository are not synonyms. Knowing which folder is open is the question the rest of the course keeps returning to.

By the end

  • Open a folder rather than a single file, and say why the window looks different
  • Answer which folder is currently open and where it sits on your computer
  • Distinguish a folder, a VS Code workspace and a Git repository
  • Explain why creating or deleting in the file tree is a real change on disk

Nearly every confusing moment later in this course traces back to one question that nobody thinks to ask: which folder is open? An agent can only reach what it has been pointed at. A command runs somewhere specific. A list of changed files is a list about one project. All of that depends on a choice made in the first few seconds, usually without noticing.

Open the folder, not the file

If you double-click an HTML file, your computer may well open it in VS Code. What you get is a window with the file in it and very little else: no file tree, nothing to navigate, no sense of a project. Microsoft’s documentation describes this state plainly, noting that when you open a file this way “some of VS Code’s capabilities are reduced but you can still open text files and edit them.”

Beginners regularly land here and conclude the application is broken or that they installed it wrong. Nothing is wrong. VS Code simply has not been told what project it is looking at.

The fix is to open the containing folder instead, through File › Open Folder. The file tree appears, search has something to search, and the terminal has somewhere to start.

If a window ever looks oddly empty — no tree, nothing in the Explorer — the first thing to check is whether you opened a file rather than a folder.

Three words for nearly the same thing

Folder, workspace and repository get used interchangeably, including by people who know better. They describe different facts about one directory, and conflating them is what makes later explanations slippery.

A Git repository True when the folder contains a hidden .git directory, which means Git is tracking changes to what is inside. A folder becomes one when someone runs git init or downloads a project that already was one.
A VS Code workspace True while VS Code has the folder open. Microsoft defines a workspace as “the collection of one or more folders that are opened in a VS Code window.” Close the window and the folder is still there; it simply is not a workspace any more.
A folder Always true. A location on your disk holding files and possibly other folders. This is the layer Finder and File Explorer show you, and the only one that exists whether or not any software is running.

The folder at the base is the only permanent fact. The other two are things that happen to be true of it right now. A folder can be a workspace without being a repository, a repository without being open in any editor, or both at once — which is the usual case and the reason the words blur.

In ordinary prose this course says project folder, and reaches for the precise word only where the distinction decides something.

Where you are on the computer

Knowing a folder’s name is not the same as knowing where it is. Two folders called notes in different places are different folders, and a tool pointed at the wrong one will look like it is doing nothing.

Paths look different by platform. On a Mac your own files sit under /Users/ and your name, with forward slashes between the parts. On Windows they sit under C:\Users\ and your name, with backslashes. You do not need to memorize the shape; you need to recognize your own path when something prints it back at you, which Module 5 will do.

One wrinkle worth knowing about in advance: if your Desktop or Documents folder is synced by OneDrive or iCloud Drive, the real path may not be where you expect, and a tool may report somewhere unfamiliar. That is normal and not a sign of a problem.

The file tree is the filesystem

VS Code calls its file tree the Explorer. What matters about it here is that it is not a project database or a list of shortcuts. Creating a file in the Explorer creates a file on disk. Renaming one renames it everywhere. Deleting one deletes it, and the undo for that is your operating system’s trash, not the editor’s undo.

There is one pleasant difference from Finder and File Explorer. Files whose names begin with a dot — .gitignore and similar — are hidden by the operating system by default, and VS Code shows them. Those files often carry configuration that changes how tools behave, so being able to see them is a genuine advantage. Module 8 returns to what they do.

Exercise: answer three questions about your own window

Download the practice project from the course landing page if you have not already, unzip it, and open the vscode-practice folder with File › Open Folder. Then answer these without guessing.

  1. Which folder is open? The name is at the top of the file tree.
  2. What is inside it? List the files, and note which entries are folders you can expand.
  3. Which file is in the editor right now? If none is, open index.html and answer again.

Then do one thing that proves the point about the filesystem. With the folder open in VS Code, open the same folder in Finder or File Explorer and put the two windows side by side. Create a file in VS Code called scratch.md, and watch it appear in the other window. Delete it again from either side.

What you should have seen

The practice folder contains index.html, styles.css, notes.md, README.md, a folder called assets holding one text file, and a folder called after-the-change that the capstone uses. Six entries, two of which expand.

The file you created appeared in the other window immediately, because there is only one file and both windows are looking at it. If deleting it from VS Code sent it to the trash rather than destroying it, that is your operating system behaving normally.

That is the whole of Module 2, and it is worth more than it looks. For the rest of the course, when something is confusing, the first question is this one: which folder is open, and is it the one I meant?