finder – How to open .cfg and .tex files with different applications on macOS?

Every time I try to change the default application to open .cfg files, all .tex files are automatically set to be opened with the same application, and vice-versa.
This is problematic since I would like to open .cfg files with TextEdit and .tex files with Texpad.
Is there a way to do this ?

I don’t know what causes this behavior, here’s what I already tried:

  • Set various editors as default app using the standard method (File > Get Info > Open With > Change All). I tried with TextEdit, Textmate, Atom, Texpad on both types of files.

  • Set default app using duti.

  • Edit ~/Library/Preferences/ to manually add entries then restart, as suggested here. The entries I edited are the following:

    {  LSHandlers = (
         {  LSHandlerContentType = "com.vallettaventures.texpadm.tex";
            LSHandlerPreferredVersions = { LSHandlerRoleAll = "-"; };
            LSHandlerRoleAll = "com.vallettaventures.texpad";
         {  LSHandlerContentTag = "cfg";
            LSHandlerContentTagClass = "public.filename-extension";
            LSHandlerPreferredVersions = { LSHandlerRoleAll = "-"; };
            LSHandlerRoleAll = "";

Unfortunately, none of these approaches have worked.

Config: I am running macOS 11.3.1 on an Intel MacBook Air.