現已釋出!閱讀關於 11 月新增功能和修復的內容。

語言識別符號

在 Visual Studio Code 中,每個語言模式都有一個唯一的特定語言識別符號。除了在設定中,使用者很少看到該識別符號,例如在將副檔名與語言關聯時

    "files.associations": {
        "*.myphp": "php"
    }

請注意,對於精確的識別符號匹配,大小寫很重要('Markdown' != 'markdown')

當新增新的語言功能或替換語言支援時,語言識別符號對於 VS Code 擴充套件開發人員至關重要。

每種語言都透過擴充套件的 package.json 檔案中的 languages 配置點定義其 id

    "languages": [{
        "id": "java",
        "extensions": [ ".java", ".jav" ],
        "aliases": [ "Java", "java" ]
    }]

使用語言識別符號新增語言支援

    "grammars": [{
        "language": "groovy",
        "scopeName": "source.groovy",
        "path": "./syntaxes/Groovy.tmLanguage.json"
    }],
    "snippets": [{
        "language": "groovy",
        "path": "./snippets/groovy.json"
    }]
languages.registerCompletionItemProvider('php', new PHPCompletionItemProvider(), '.', '$');

新識別符號指南

在定義新的語言識別符號時,請使用以下準則

  • 使用程式語言名稱的小寫形式。
  • 在 Marketplace 中搜索其他擴充套件,以確定是否已使用某個語言識別符號。

已知語言識別符號

下表列出了已知的語言識別符號

語言 識別符號
ABAP abap
Windows Bat bat
BibTeX bibtex
Clojure clojure
Coffeescript coffeescript
C c
C++ cpp
C# csharp
Compose dockercompose
CSS css
CUDA C++ cuda-cpp
D d
Dart dart
Delphi pascal
Diff diff
Dockerfile dockerfile
Erlang erlang
F# fsharp
Git git-commitgit-rebase
Go go
Groovy groovy
Handlebars handlebars
Haml haml
Haskell haskell
HTML html
Ini ini
Java java
JavaScript javascript
JavaScript JSX javascriptreact
JSON json
帶註釋的 JSON jsonc
Julia julia
LaTeX latex
Less less
Lua lua
Makefile makefile
Markdown Markdown
Objective-C objective-c
Objective-C++ objective-cpp
OCaml ocaml
Pascal pascal
Perl perlperl6
PHP php
純文字 plaintext
PowerShell powershell
Pug jade, pug
Python python
R r
Razor (cshtml) razor
Ruby ruby
Rust rust
SCSS scss(使用大括號的語法), sass(縮排語法)
ShaderLab shaderlab
Shell Script (Bash) shellscript
Slim slim
SQL sql
Stylus stylus
Svelte svelte
Swift swift
TypeScript typescript
TypeScript JSX typescriptreact
TeX tex
Visual Basic vb
Vue vue
Vue HTML vue-html
XML xml
XSL xsl
YAML yaml
© . This site is unofficial and not affiliated with Microsoft.