Skip to content

Zed

Zed Industries

由 Atom 团队构建的高性能代码编辑器,内置 AI 功能和实时协作。

Official Site
01

概述

Zed 是一款用 Rust 编写的高性能代码编辑器,由 Atom 编辑器的创作者开发。其核心理念是速度,从启动到运行都追求极致性能。Zed 使用 GPUI 引擎进行 GPU 加速渲染,支持编辑数百万行的文件而不卡顿。内置 AI 助手、实时协作、集成终端等,是面向现代开发者的下一代编辑器。Zed 是开源的,支持 macOS 和 Linux。

02

安装

Zed 支持 macOS 和 Linux(Windows 版本正在开发中)。可通过官网下载或包管理器安装。安装后首次启动会引导你进行配置。

bash
# macOS
curl -f https://zed.dev/install.sh | sh

# Or via Homebrew
brew install --cask zed

# Linux
curl -f https://zed.dev/install.sh | sh

# Or download the AppImage
# Download from https://zed.dev/download
03

配置

Zed 使用 JSON 进行配置,配置文件位于 ~/.config/zed/settings.json。支持配置主题、字体、快捷键、AI、协作等。配置采用分层结构,支持项目级配置。

bash
// settings.json
{
  "theme": "One Dark",
  "buffer_font_family": "JetBrains Mono",
  "buffer_font_size": 14,
  "tab_size": 2,
  "features": {
    "copilot": true
  },
  "assistant": {
    "default_model": "gpt-4",
    "version": "2"
  }
}
04

快捷键

Zed 提供高效的键盘快捷键,支持 Vim、Emacs、VS Code 等键位方案。可通过 keymap.json 自定义快捷键。Zed 的命令面板(Cmd+Shift+P)提供对所有功能的快速访问。

bash
// keymap.json
[
  {
    "context": "Editor",
    "bindings": {
      "cmd-shift-a": "editor::selectAll",
      "ctrl-cmd-f": "editor::format"
    }
  },
  {
    "context": "Pane",
    "bindings": {
      "alt-1": "pane::activateItem 0"
    }
  }
]
05

AI 功能

Zed 内置 AI 助手,支持 OpenAI、Anthropic、GitHub Copilot 等。它可以生成代码、解释代码、重构、修复 bug 等。AI 助手与编辑器深度集成,能理解当前文件和项目上下文。支持内联编辑和侧边栏聊天。

bash
// Use the AI assistant
// Cmd+I: inline edit
// Cmd+Shift+A: open the assistant panel

// In the assistant panel:
// "Add type annotations to this function"
// "Explain the logic of this code"
// "Refactor this component and extract subcomponents"
06

协作

Zed 提供实时协作功能,允许多人同时编辑同一文件。协作功能基于 CRDT 技术,支持低延迟同步。可以共享项目、终端和聊天记录。协作无需额外服务,直接通过 Zed 的基础设施工作。

bash
# Start a collaboration session
# In Zed: Cmd+Shift+P -> "collaboration: open"

# Invite others
# Share the session link with teammates
# Teammates click the link to join the session
07

扩展

Zed 支持扩展系统,允许安装语言支持、主题、工具等扩展。扩展通过 Zed 的扩展商店安装。支持 WASM 扩展,确保安全性和性能。社区正在积极开发更多扩展。

bash
# Install extensions
# In Zed: Cmd+Shift+P -> "zed: extensions"

# Common extensions
# - Language Support (various languages)
# - Emmet
# - Git Integration
# - Themes
08

主题

Zed 自带多款精美主题并支持自定义。主题以 JSON 格式定义,可精确控制颜色、字体、图标等。社区提供大量主题可供选择。支持亮色和暗色模式之间的自动切换。

bash
// Custom theme
// ~/.config/zed/themes/my-theme.json
{
  "name": "My Theme",
  "author": "Me",
  "themes": [{
    "appearance": "dark",
    "style": {
      "background": "#1e1e2e",
      "foreground": "#cdd6f4",
      "syntax": {
        "keyword": "#cba6f7",
        "string": "#a6e3a1"
      }
    }
  }]
}
09

性能

Zed 的核心优势是性能。用 Rust 编写,使用 GPUI 引擎进行 GPU 加速渲染,Tree-sitter 进行增量解析。启动时间 <1 秒,可流畅编辑数百万行的文件。内存占用低,响应速度快。Zed 的性能远超 Electron 编辑器。

10

远程开发

Zed 支持远程开发,允许你连接到远程服务器进行开发。通过 SSH 连接,代码在远程服务器上运行,本地编辑器提供 UI。支持容器开发,与 Docker 集成。远程开发体验几乎与本地相同。

bash
# Remote development configuration
// settings.json
{
  "remote": {
    "projects": {
      "my-server": {
        "host": "server.example.com",
        "username": "user",
        "paths": ["/home/user/project"]
      }
    }
  }
}

Ready to try Zed?

Visit the official site for the latest version and full documentation.

Visit Zed