How to change syntax for a specific folder in Sublime Text 3

I write JS projects in ES5 and ES6. I installed Babel-Sublime for highlighting Babel supported code. Now, I open a .js file written in ES6, goto "View -> syntax -> Open all with current extension as : Javascript (Babel)", but this causes my ES5 code to also switch to Javascript (Babel). Basically,the JavaScript (Babel).sublime-settings file is updated in the User folder with the extension mapping and the change is applied globally to all my projects. So, is there a way to specify "syntax to extension" mapping per folder or per project basis


Solution 1:

First you can specify project-level settings using your_project_name.sublime-project file. Take a look at Project menu and the sublime documentation.

Though, sublime doesn't support syntax settings in the .sublime-project files. So you have to use Sublime Project Specific Syntax package. This works for me with Sublime Text 3. Pay attention to use the Project Specific Syntax > Copy syntax setting to clipboard menu item.

For Babel-Sublime syntax highlighting following should work:

{
    "folders":
    [
        {
            "path": "."
        }
    ],
  "syntax_override": {
    "\\.js$": ["Babel", "JavaScript (Babel)"]
  }
}