Mac guide

How to make Visual Studio Code the default code editor on Mac

Works on macOS Sonoma, Sequoia and Tahoe.

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

  1. Select a file of the first type in Finder and press ⌘ I.
  2. Under Open with, choose Visual Studio Code.
  3. Click Change All… and confirm.
  4. 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

  1. Open Defaultify and search for the extension, or drag a file onto the window.
  2. Choose Visual Studio Code from the app menu on each row.
  3. 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.

Get Defaultify for Mac

Related guides