I tried grg's solution in the past and I believe it worked. However, on Yosemite and El Capitan, I ran into problems.
DonnaLea's comment in that solution clued me in on creating a solution. I added the folder path before com.apple.launchservices
additionally the file had a slightly different name com.apple.launchservices.secure
.
You can see the file/folders being modified in the following path:
/user/Library/Preferences/com.apple.LaunchServices/com.apple.launchservices.secure.plist
Screenshot for reference: [![enter image description here][1]][1]
Here's the command I used in terminal:
defaults write com.apple.LaunchServices/com.apple.launchservices.secure LSHandlers -array-add \
'{LSHandlerContentType=public.plain-text;LSHandlerRoleAll=com.sublimetext.3;}'
Lastly, after a restart to my machine it worked as advertised. [1]: https://i.sstatic.net/qQOQg.jpg