Skip to content

主题与字体

这一章解决什么问题

帮助你个性化 Zed 的外观,选择合适的主题和字体。

资料来源

你会在什么时候用到它

  • 想换一个好看的主题时
  • 字体显示不清晰或不习惯时
  • 想让编辑器更符合个人审美时

主题设置

切换主题

  1. Ctrl+Shift+P → 输入 theme
  2. 选择 Preview Theme 预览
  3. 选择喜欢的主题

主题配置

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

跟随系统主题

Zed 可以自动跟随 Windows 的明暗主题设置:

json
{
  "theme": {
    "mode": "system"
  }
}

Windows 切换明暗模式时,Zed 会自动切换对应主题。

推荐主题

Zed 内置主题:

主题名类型特点
One Dark暗色经典深色,对比度适中
One Light亮色经典浅色,清晰易读
Gruvbox Dark暗色暖色调,护眼
Gruvbox Light亮色暖色调浅色
Catppuccin双版本柔和色彩,流行
Rose Pine双版本自然色系

安装新主题

从扩展市场安装:

  1. Ctrl+Shift+Pextensions
  2. 搜索主题名(如 "Catppuccin")
  3. 点击安装
  4. 安装后在 theme 设置中使用

字体设置

代码字体

json
{
  "buffer_font_family": "Cascadia Code",
  "buffer_font_size": 14,
  "buffer_font_features": {
    "calt": true,
    "liga": true
  }
}

Windows 推荐编程字体

字体特点获取方式
Cascadia Code微软出品,清晰,连字Windows Terminal 自带 / GitHub 下载
Fira Code流行,连字丰富GitHub 下载
JetBrains MonoJetBrains 出品,易读JetBrains 官网下载
Maple Mono中文优化,开源GitHub 下载
Sarasa Gothic(更纱黑体)中英文等宽GitHub 下载

安装字体

  1. 下载字体文件(.ttf 或 .otf)
  2. 双击字体文件
  3. 点击 安装
  4. 在 Zed 设置中使用字体名

确认字体名

安装后在 Zed 中使用字体的家族名(Family Name),不是文件名。可以在 Windows 字体设置中查看。

界面字体

json
{
  "ui_font_family": ".SystemUIFont",
  "ui_font_size": 16
}

.SystemUIFont 会自动使用 Windows 系统默认字体,通常对中文支持良好。

字体连字(Ligatures)

字体连字将某些字符组合显示为特殊符号:

!=  →  ≠
=>  →  ⇒
>=  →  ≥
<=  →  ≤

开启连字:

json
{
  "buffer_font_features": {
    "calt": true,
    "liga": true
  }
}

连字字体

不是所有字体都支持连字。推荐 Cascadia Code、Fira Code、JetBrains Mono,它们都原生支持连字。

视觉微调

行高

json
{
  "buffer_line_height": {
    "custom": 1.5
  }
}

字符间距

json
{
  "buffer_font_features": {
    "ss01": true
  }
}

光标样式

json
{
  "cursor_shape": "bar"
}

选项:"bar"(竖线)、"block"(方块)、"underline"(下划线)

光标闪烁

json
{
  "cursor_blink": true
}

显示行号

json
{
  "gutter": {
    "line_numbers": true
  }
}

当前行高亮

json
{
  "current_line_highlight": "all"
}

选项:"all""gutter""none"

缩进向导线

json
{
  "indent_guides": {
    "enabled": true,
    "coloring": "indent_aware"
  }
}

本章小结

  • 主题支持跟随 Windows 系统明暗切换
  • 推荐编程字体:Cascadia Code、Fira Code、JetBrains Mono
  • 字体连字让代码更美观
  • 可以微调行高、光标、行号等视觉细节

小练习

  1. 安装一个新主题并切换
  2. 安装 Cascadia Code 字体并配置
  3. 调整行高和光标样式,找到最舒服的设置

基于 Zed 官方文档及社区资料整理,仅供学习参考