The solutions proposed here work perfectly for Sublime, but I wanted to do this for Visual Studio Code. The only difference is that you have to find the "application bundle identifier" for whatever text editor you use. I ran this command:
/usr/libexec/PlistBuddy -c 'Print CFBundleIdentifier' /Applications/Visual\ Studio\ Code.app/Contents/Info.plist
link for referencelink for reference
to get the identifier "com.microsoft.VSCode". Then I installed "duti" and ran this command:
duti -s com.microsoft.VSCode public.plain-text all
This should work for any text editor you want that is installed under /Applications. I hope this helps non-Sublime users.