Set language for syntax highlighting in Visual Studio Code

后端 未结 6 1079
庸人自扰
庸人自扰 2020-11-30 16:33

Before the confusion begins, this question is about Code, the new lightweight Visual Studio Editor. You can get it from here: https://code.visualstudio.com/

I have a

6条回答
  •  自闭症患者
    2020-11-30 17:30

    Note that for "Untitled" editor ("Untitled-1", "Untitled-2"), you now can set the language in the settings.

    The previous setting was:

    "files.associations": {
            "untitled-*": "javascript"
     }
    

    This will not always work anymore, because with VSCode 1.42 (Q1 2020) will change the title of those untitled editors.
    The title will now be the first line of the document for the editor title, along the generic name as part of the description.
    It won't start anymore with "untitled-"

    See "Untitled editor improvements"

    Regarding the associated language for those "Untitled" editors:

    By default, untitled files do not have a specific language mode configured.

    VS Code has a setting, files.defaultLanguage, to configure a default language for untitled files.

    With this release, the setting can take a new value {activeEditorLanguage} that will dynamically use the language mode of the currently active editor instead of a fixed default.

    In addition, when you copy and paste text into an untitled editor, VS Code will now automatically change the language mode of the untitled editor if the text was copied from a VS Code editor:

    And see workbench.editor.untitled.labelFormat in VSCode 1.43.

提交回复
热议问题