How to make Visual Studio Code the default code editor on Mac
Installing VS Code does not change what opens your files. Each source and data type keeps its old default, usually Xcode or TextEdit, and macOS makes you change them one extension at a time.
The file types involved: .json, .md, .py, .js, .ts, .yaml, .xml, .sh, .txt, .log, .csv.
In Finder, one type at a time
- Select a file of the first type in Finder and press ⌘ I.
- Under Open with, choose Visual Studio Code.
- Click Change All… and confirm.
- Repeat with a file of each other type. You need one sample file per extension.
From Terminal, all at once
The free command-line tool duti sets defaults without Finder. Install it with Homebrew:
brew install duti
for ext in json md py js ts yaml xml sh txt log csv; do duti -s com.microsoft.VSCode .$ext all; done
The first argument is the app's bundle identifier. To find it for any app:
osascript -e 'id of app "Visual Studio Code"'
macOS may still ask you to confirm the change.
In Defaultify
- Open Defaultify and search for the extension, or drag a file onto the window.
- Choose Visual Studio Code from the app menu on each row.
- Confirm in the Finder dialog.
With Defaultify Pro, a profile changes a whole set of types together, and you can switch back with one click.
There is no “all code files” switch in macOS
Every extension is its own type, so a developer's Mac has dozens of defaults to move. Doing it in Finder means finding a sample file for each one. The Terminal loop below, or a Developer profile in Defaultify, does them in one go.
Manage every default in one place
Defaultify for Mac shows all your file-type and link defaults in one window, flags missing ones, and with Pro warns you when an app takes one over.
Related guides
- Change the default app for JSON files
- Change the default app for Markdown (.md) files
- Change the default app for Python (.py) files
- Change the default app for XML files
- Change the default app for text (.txt) files
- Change the default app for CSV files
- “Always Open With” not working
- Stop apps from changing your defaults