How to make VS Code to treat other file extensions as certain language?

后端 未结 9 1386
傲寒
傲寒 2020-11-27 09:35

Or is there a way to switch the current file\'s language to use syntax highlight feature?

For example, *.jsx actually uses JavaScript but VS Code doesn\

相关标签:
9条回答
  • 2020-11-27 10:13

    eg:

    // .vscode/settings.json in workspace
    
    {
      "files.associations": {
        "*Container.js": "javascriptreact",
        "**/components/*/*.js": "javascriptreact",
        "**/config/routes.js": "javascriptreact"
      }
    }
    
    0 讨论(0)
  • 2020-11-27 10:14

    In Visual Studio Code, you can add persistent file associations for language highlighting to your settings.json file like this:

    // Place your settings in this file to overwrite the default settings
    {
      "some_setting": custom_value,
      ...
    
      "files.associations": {
        "*.thor": "ruby",
        "*.jsx": "javascript",
        "Jenkinsfile*": "groovy"
      }
    }
    

    You can use Ctrl+Shift+p and then type settings JSON. Choose Preferences: Open Settings (JSON) to open your settings.json.

    The Files: Associations feature was first introduced in Visual Studio Code version 1.0 (March 2016). Check the available wildcard patterns in the release notes and the known language strings in the documentation.

    0 讨论(0)
  • 2020-11-27 10:15

    This works for me.

    {
    "files.associations": {"*.bitesize": "yaml"}
     }
    
    0 讨论(0)
提交回复
热议问题