Skip to main content

Changing the Default Text Editor on MacOS

This should change it for all files including hidden files in the file system.

# Sublime Text 4
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers \
-array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.4;}'

# VS Code
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers \
-array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.microsoft.VSCode;}'

 

Source