Chapter 07 · Editing and files编辑与文件編輯與檔案

Syntax highlighting and languages语法高亮与语言語法高亮與語言

The 36 supported languages, auto-detection by file name, manual override and how highlighting scales.36 种语言、按文件名自动识别、手动切换,以及高亮的性能策略。36 種語言、按檔案名自動識別、手動切換,以及高亮的效能策略。

Supported languages

Plain Text, HTML, CSS, SCSS, Less, JavaScript, TypeScript, JSON, Python, Java, Kotlin, Scala, XML, Markdown, C++, C#, Objective-C, Swift, Go, Rust, Dart, Ruby, PHP, Perl, Lua, R, Shell, SQL, YAML, TOML, INI, Dockerfile, Makefile, LaTeX, Protocol Buffers, GraphQL — 36 in total.

Automatic detection

  • Detection is based on the file name and extension, not on content sniffing.
  • Extension-less files with well-known names (Dockerfile, Makefile) are recognised.
  • Ambiguous extensions can be overridden from the language menu in the status bar.

What is coloured

Keywords, strings, numbers, comments, type names, function names, variables, tags and attributes. The palette follows the active theme, including the comparison colours when a diff is installed.

Scaling strategy

File sizeBehaviour
SmallWhole document highlighted synchronously.
Medium / largeVisible region first, remaining chunks analysed in the background.
Above the line thresholdCanvas rendering path with a sliding window; only what is on screen is laid out.

Background analysis reads a document snapshot taken on the main thread, so it never races with live edits.

Markdown

Markdown is highlighted as source: headings, emphasis markers, code fences and links are coloured. There is no rendered preview and no Mermaid or diagram rendering in 1.0.110.

Switching manually

Click the language segment in the status bar and pick a language. The choice applies to the current document only; reopening the file returns to auto-detection.

支持的语言

Plain Text、HTML、CSS、SCSS、Less、JavaScript、TypeScript、JSON、Python、Java、Kotlin、Scala、XML、Markdown、C++、C#、Objective-C、Swift、Go、Rust、Dart、Ruby、PHP、Perl、Lua、R、Shell、SQL、YAML、TOML、INI、Dockerfile、Makefile、LaTeX、Protocol Buffers、GraphQL——共 36 种。

自动识别

  • 识别依据是文件名与扩展名,不做内容嗅探。
  • Dockerfile、Makefile 这类没有扩展名的常见文件也能识别。
  • 扩展名有歧义时,可在状态栏的语言菜单中手动覆盖。

着色范围

关键字、字符串、数字、注释、类型、函数名、变量、标签与属性。配色跟随当前主题;安装比较结果后也会使用比较配色。

性能策略

文件规模行为
小文件全文档同步高亮。
中 / 大文件先着色可见区域,其余分块后台补齐。
超过行数阈值切换到 Canvas 渲染与滑动窗口,只排版屏幕内的内容。

后台分析读取主线程捕获的文档快照,不会与实际编辑产生竞争。

Markdown

Markdown 按源码高亮:标题、强调标记、代码围栏与链接都会着色。1.0.110 没有渲染预览,也不支持 Mermaid 或图表渲染。

手动切换

点击状态栏语言片段并选择语言。选择只对当前文档生效;重新打开文件会回到自动识别。

支援的語言

Plain Text、HTML、CSS、SCSS、Less、JavaScript、TypeScript、JSON、Python、Java、Kotlin、Scala、XML、Markdown、C++、C#、Objective-C、Swift、Go、Rust、Dart、Ruby、PHP、Perl、Lua、R、Shell、SQL、YAML、TOML、INI、Dockerfile、Makefile、LaTeX、Protocol Buffers、GraphQL——共 36 種。

自動識別

  • 識別依據是檔案名與副檔名,不做內容嗅探。
  • Dockerfile、Makefile 這類沒有副檔名的常見檔案也能識別。
  • 副檔名有歧義時,可在狀態列的語言選單中手動覆蓋。

著色範圍

關鍵字、字串、數字、注釋、類型、函數名、變數、標籤與屬性。配色跟隨當前主題;安裝比較結果後也會使用比較配色。

效能策略

檔案規模行為
小檔案全文件同步高亮。
中 / 大檔案先著色可見區域,其餘分塊後台補齊。
超過行數閾值切換到 Canvas 渲染與滑動視窗,只排版螢幕內的內容。

後台分析讀取主執行緒捕獲的文件快照,不會與實際編輯產生競爭。

Markdown

Markdown 按原始碼高亮:標題、強調標記、程式碼圍欄與連結都會著色。1.0.110 沒有渲染預覽,也不支援 Mermaid 或圖表渲染。

手動切換

點擊狀態列語言片段並選擇語言。選擇只對當前文件生效;重新開啟檔案會回到自動識別。