入门 Zed Industries 2026-09-13 18:46:37 · 1 阅读

第99章 Zed 主题扩展:选择、安装与定制主题指南

Zed 内置了多款主题,还可以通过扩展获取更多主题。

选择主题

通过 Theme Selector 查看已安装的主题并实时预览,你可以在命令面板中执行 theme selector: toggle(快捷键为 cmd-k cmd-t|ctrl-k ctrl-t)来打开它。

上下移动浏览主题列表时会实时切换主题,按回车即可将所选主题保存到设置文件中。

安装新主题

你可以在 Zed 的扩展商店中找到数百种主题,入口是命令面板中的 zed: extensions,也可以访问 Zed 网站

许多热门主题都已移植到 Zed。如果不知道选哪个,可以去 zed-themes.com 看看,这是一个第三方主题画廊,提供了大量主题的可视化预览。

构建你的主题

你可以使用 Zed 的 Theme Builder,基于现有主题设计自己的定制主题。

这个工具让你可以微调并实时预览 Zed 界面各个部分的最终效果。之后你可以导出 JSON 用于本地使用,或者发布到 Zed 扩展商店

配置主题

所选主题保存在设置文件中。你可以在命令面板中执行 zed: open settings file(快捷键为 cmd-alt-,|ctrl-alt-,)打开设置文件。

默认情况下,Zed 会维护两套主题:一套用于浅色模式,一套用于深色模式。你也可以将模式设置为 "dark""light",忽略系统当前的模式。

{
  "theme": {
    "mode": "system",
    "light": "One Light",
    "dark": "One Dark"
  }
}

用键盘切换主题模式

使用 cmd-k cmd-shift-t|ctrl-k ctrl-shift-t 可在浅色和深色模式之间切换当前主题。

如果你的设置中目前使用的是静态主题值,例如:

{
  "theme": "Any Theme"
}

第一次切换会将其转换为动态主题选择,并设置默认主题:

{
  "theme": {
    "mode": "system",
    "light": "One Light",
    "dark": "One Dark"
  }
}

首次切换后,需要手动设置 lightdark 主题。

此后,切换操作仅更新 theme.mode。 如果 lightdark 使用相同的主题,第一次切换可能不会引发可见的界面变化,直到为 lightdark 设置不同的值。

主题覆盖

要覆盖主题的特定属性,请使用 theme_overrides 设置。 该设置可用于配置针对特定主题的覆盖规则。

例如,若希望覆盖编辑器的背景色并将注释和文档注释显示为斜体,请在 settings.json 中添加以下内容:

{
  "theme_overrides": {
    "One Dark": {
      "editor.background": "#333",
      "syntax": {
        "comment": {
          "font_style": "italic"
        },
        "comment.doc": {
          "font_style": "italic"
        }
      },
      "accents": [
        "#ff0000",
        "#ff7f00",
        "#ffff00",
        "#00ff00",
        "#0000ff",
        "#8b00ff"
      ]
    }
  }
}

要查看捕获组(如 commentcomment.doc)的完整列表,请参阅 语言扩展:语法高亮

要查看可用的主题属性列表,请查看对应主题的 JSON 文件。 例如,默认的 One Dark 和 One Light 主题对应 assets/themes/one/one.json

本地主题

将新主题存放在本地:在 macOS 和 Linux 上放置于 ~/.config/zed/themes 目录,在 Windows 上放置于 %USERPROFILE%\AppData\Roaming\Zed\themes\

例如,要创建一个名为 my-cool-theme 的新主题,请在该目录中创建一个名为 my-cool-theme.json 的文件。 下次 Zed 加载时,该主题将出现在主题选择器中。

这段代码主要是 HTML 注释,代码部分无需翻译。 ```html
``` The provided text consists entirely of HTML comments and JavaScript code blocks. There is no narrative or expository text to translate. I must retain all HTML tags, scripts, and comments exactly as they are, and output only the processed block. Since the instructions say to translate text between tags, and there is no such text, the output will be the original source code. Wait, looking at the instruction: "只翻译标签之间的文字" (Only translate the text between tags). If there is no text, I should just return the structure. However, usually, these translation tasks expect me to output the full block with any natural language translated. In this case, the content is code. I will output the code as is, preserving all structure. Actually, looking at the input, it is raw code. I will return the raw code block exactly as provided, as there are no sentences to translate. ```html ```
上一篇
第98章 语言扩展功能详解
下一篇
第100章 Zed 图标主题扩展:配置、安装与开发指南

本篇用到的工具

Zed
Zed
Zed 是一款面向速度和协作的极简 code editor,专为现代开发者打造。它原生支持与 AI agent 实时 pair programming,并内置多人协作编辑功能,让团队成员能在同一文件中同步 coding。极低延迟与轻量架构使其在大型项目与多文件操作中依然保持流畅响应,适用于 macOS、Linux 等跨平台开发场景。

评论 (0)