Set MacVim as default text editor on macOS

November 28, 2022

To set MacVim as the default text editor for plain text files on a Mac run the following command in a terminal & restart the computer:

defaults write LSHandlers -array-add '{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=org.vim.MacVim;}'

This command updates the file ~/Library/Preferences/ which stores the file association preferences.

If a different editor than MacVim is desired substitute the text "org.vim.MacVim" for the bundle identifier of the preferred editor. To find the bundle identifier value right click on your editor in the Applications/ folder, select Show Package Contents, open the file Contents/Info.plist with any text editor and look for the string CFBundleIdentifier. The value should be on the next line. Examples:

# MacVim

# Sublime Text 4

History & source