Darragh ORiordan

  • About
  • Articles
  • Projects
  • Hire

Socials & Contact

  • Follow on Twitter
  • Follow on GitHub
  • Follow on LinkedIn
  • mailto:disco@darraghoriordan.com

Explore

  • About
  • Articles
  • Projects
  • Hire
  • Privacy Policy

© 2026 Darragh ORiordan. All rights reserved.

Set VS Code as the default editor on macOS

  • #tools
Photo by Markus Spiske on Unsplash
Published September 15, 2021 · Updated September 3, 2026

To make VS Code the default editor on macOS, use duti for Finder file associations, install the official code command in your shell, and set Git's core.editor to code --wait.

I'll first describe how to configure vs code as the editor when you open a file in Finder. The second section will describe how to set code as the editor in shell and git.

Set VS Code as the default editor in macOS Finder

  1. First you should find the name of your vscode editor. Use this shell command.
osascript -e 'id of app "Visual Studio Code"'

This will probably return com.microsoft.VSCode. Use the command output on your Mac in the script below if it's different.

  1. You will use duti to change the default handler for a file type on mac. Install duti with brew or your package manager.
brew install duti
  1. To set all text files and code files to vscode instead of xcode use this set of shell commands.
duti -s com.microsoft.VSCode public.json all
duti -s com.microsoft.VSCode public.plain-text all
duti -s com.microsoft.VSCode public.python-script all
duti -s com.microsoft.VSCode public.shell-script all
duti -s com.microsoft.VSCode public.source-code all
duti -s com.microsoft.VSCode public.text all
duti -s com.microsoft.VSCode public.unix-executable all
# this works for files without a filename extension
duti -s com.microsoft.VSCode public.data all

duti -s com.microsoft.VSCode .c all
duti -s com.microsoft.VSCode .cpp all
duti -s com.microsoft.VSCode .cs all
duti -s com.microsoft.VSCode .css all
duti -s com.microsoft.VSCode .go all
duti -s com.microsoft.VSCode .java all
duti -s com.microsoft.VSCode .js all
duti -s com.microsoft.VSCode .sass all
duti -s com.microsoft.VSCode .scss all
duti -s com.microsoft.VSCode .less all
duti -s com.microsoft.VSCode .vue all
duti -s com.microsoft.VSCode .cfg all
duti -s com.microsoft.VSCode .json all
duti -s com.microsoft.VSCode .jsx all
duti -s com.microsoft.VSCode .log all
duti -s com.microsoft.VSCode .lua all
duti -s com.microsoft.VSCode .md all
duti -s com.microsoft.VSCode .php all
duti -s com.microsoft.VSCode .pl all
duti -s com.microsoft.VSCode .py all
duti -s com.microsoft.VSCode .rb all
duti -s com.microsoft.VSCode .ts all
duti -s com.microsoft.VSCode .tsx all
duti -s com.microsoft.VSCode .txt all
duti -s com.microsoft.VSCode .conf all
duti -s com.microsoft.VSCode .yaml all
duti -s com.microsoft.VSCode .yml all
duti -s com.microsoft.VSCode .toml all

Set VS Code as the shell and Git editor

  1. Install code on your command line. Launch VS Code, open the Command Palette with Cmd+Shift+P, and run Shell Command: Install 'code' command in PATH. Restart the terminal afterwards. This is the method in the current VS Code macOS setup guide.

  2. Set these environment variables in your shell configuration, usually ~/.zshrc or ~/.bashrc.

export EDITOR="code"
export VISUAL="code"
  1. Now set the git config to use vscode
git config --global core.editor "code --wait"

Summary

That's it! You should be able to open any of those kinds of files with VSCode on your Mac now.

Update 29 Jan 2022 - I added this and more to comprehensive instructions for configuring a modern developer shell and MAcOS in another article here.

You can save hours of time settings up a new machine by purchasing my full set developer environment setup scripts with this and a lot more built-in - https://darraghoriordan.gumroad.com/l/devshell.

Hey! Are you a developer?

🚀 Set Up Your Dev Environment in Minutes, Not Hours!

Tired of spending hours setting up a new development machine? I used to be, too—until I automated the entire process!

Now, I just run a single script, grab a coffee, and let my setup take care of itself.

Save 30+ hours configuring a new Mac or Windows (WSL) development environment.
Ensure consistency across all your machines.
Eliminate tedious setup and get coding faster!
Get Instant Access →