On 14 Oct 2019, at 10:55, Umberto Cerrato wrote:

e.g. I want C/C++ files to open with this new theme. I can do it in the way you suggested me. And that’s good.
But since this theme works well only with C and C++ files, I do not want it to be available/selectable/take effect if there is an opened file with a different extension than .c or .cpp etc.

What you can do is open the .tmTheme file and insert this under the root <dict> element:

<key>hideFromUser</key>
<true/>

This will cause the theme to be hidden from the View menu, though also for C/C++ files.