Skip to main content

编辑器集成

为了充分利用 Prettier,建议从你的编辑器运行它。

¥To get the most out of Prettier, it’s recommended to run it from your editor.

如果你的编辑器不支持 Prettier,你可以用 使用文件监视器运行 Prettier 代替。

¥If your editor does not support Prettier, you can instead run Prettier with a file watcher.

注意!在每个项目中本地 install Prettier 很重要,因此每个项目都获得正确的 Prettier 版本。

¥Note! It’s important to install Prettier locally in every project, so each project gets the correct Prettier version.

Visual Studio Code

prettier-vscode 可以使用扩展侧边栏安装 - 它被称为“Prettier - 代码格式化程序。” 检查其存储库以获取配置和快捷方式

¥prettier-vscode can be installed using the extension sidebar – it’s called “Prettier - Code formatter.” Check its repository for configuration and shortcuts.

如果你想打开和关闭格式化程序,请安装 vscode-status-bar-format-toggle

¥If you’d like to toggle the formatter on and off, install vscode-status-bar-format-toggle.

Emacs

查看 prettier-emacs 存储库或 prettier.el阿菲莱亚 包支持多种代码格式化程序,包括 Prettier。

¥Check out the prettier-emacs repo, or prettier.el. The package Apheleia supports multiple code formatters, including Prettier.

Vim

vim-prettier 是 Prettier 特定的 Vim 插件。NeoformatALEcoc-prettier 是支持 Prettier 的多语言 Vim linter/formatter 插件。

¥vim-prettier is a Prettier-specific Vim plugin. Neoformat, ALE, and coc-prettier are multi-language Vim linter/formatter plugins that support Prettier.

有关更多详细信息,请参阅 Vim 安装指南

¥For more details see the Vim setup guide.

Helix

可以在 Helix 语言配置 中指定格式化程序,该格式化程序将优先于任何语言服务器。

¥A formatter can be specified in your Helix language configuration, which will take precedence over any language servers.

欲了解更多详情,请参阅 Prettier 的 Helix 外部二进制格式化程序配置

¥For more details see the Helix external binary formatter configuration for Prettier.

Sublime Text

Sublime Text 支持可通过 Package Control 和 JsPrettier 插件获得。

¥Sublime Text support is available through Package Control and the JsPrettier plug-in.

JetBrains WebStorm、PHPStorm、PyCharm...

参见 WebStorm 设置指南

¥See the WebStorm setup guide.

Visual Studio

安装 JavaScript Prettier 扩展

¥Install the JavaScript Prettier extension.

Espresso

Espresso 用户可以安装 espresso-prettier 插件。

¥Espresso users can install the espresso-prettier plugin.