Scripts2026年5月18日·1 分钟阅读

Ace — High-Performance Code Editor for the Browser

A high-performance, embeddable code editor written in JavaScript that brings native-editor features like syntax highlighting, auto-completion, and code folding to the browser.

Agent 就绪

这个资产可以被 Agent 直接读取和安装

TokRepo 同时提供通用 CLI 命令、安装契约、metadata JSON、按适配器生成的安装计划和原始内容链接,方便 Agent 判断适配度、风险和下一步动作。

Needs Confirmation · 66/100策略:需确认
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
Ace Editor
通用 CLI 安装命令
npx tokrepo install c8e01b43-524e-11f1-9bc6-00163e2b0d79

Introduction

Ace is an embeddable code editor that powers the editing experience in Cloud9 IDE, GitHub's code view, and many other web-based developer tools. It provides a feature set comparable to native editors including syntax highlighting for over 150 languages, multiple cursors, code folding, and search-and-replace with regex.

What Ace Does

  • Provides syntax highlighting and language modes for 150+ programming languages
  • Supports multiple cursors, block selection, and simultaneous editing
  • Offers auto-completion with language-aware snippets and live syntax checking
  • Handles large files efficiently with virtual rendering that only draws visible lines
  • Includes 30+ built-in themes and full keyboard shortcut customization

Architecture Overview

Ace uses a model-view architecture. The EditSession holds the document model, tokenizer state, and undo history. The VirtualRenderer draws only the visible viewport using absolutely positioned DOM elements, enabling smooth scrolling through files with hundreds of thousands of lines. A worker thread runs syntax validation and language analysis off the main thread.

Self-Hosting & Configuration

  • Include via CDN or install with npm install ace-builds
  • Call ace.edit(element) to attach the editor to any DOM container
  • Set language mode with editor.session.setMode('ace/mode/python')
  • Apply a theme with editor.setTheme('ace/theme/github')
  • Enable live syntax checking with editor.session.setUseWorker(true) (on by default for supported modes)

Key Features

  • Virtual rendering for smooth performance on files exceeding 100K lines
  • Integrated search with regex, case sensitivity, and whole-word options
  • Code folding, bracket matching, and indent guides
  • Vim, Emacs, and Sublime Text keybinding modes
  • Accessible with ARIA attributes and configurable font sizes for readability

Comparison with Similar Tools

  • CodeMirror 6 — Modular rewrite with better extensibility and accessibility; Ace has more built-in language modes
  • Monaco Editor — Powers VS Code with richer IntelliSense; larger bundle than Ace
  • Prism.js / highlight.js — Read-only syntax highlighting; Ace is a full interactive editor
  • Quill / Tiptap — Rich text editors for prose; Ace is purpose-built for source code
  • CodeFlask — Lightweight embeddable editor; lacks Ace's scale for large files and advanced features

FAQ

Q: How does Ace handle very large files? A: Ace uses virtual rendering, drawing only the lines visible in the viewport. This lets it handle files with hundreds of thousands of lines without DOM bloat.

Q: Can I use Ace in a React or Vue project? A: Yes. Community wrappers like react-ace and vue-ace-editor provide component-based integration with two-way binding.

Q: Is Ace still actively maintained? A: Yes. Ace continues to receive updates on GitHub with regular bug fixes and new language modes.

Q: How do I add custom auto-completions? A: Register a completer object with editor.completers.push() that implements getCompletions(editor, session, pos, prefix, callback).

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产