Code Style (VS Code Extension)
中文说明
该扩展通过 code.style.settings.url 指定的 Eclipse 格式化 XML(可由 IntelliJ IDEA 导出)来格式化代码。
使用方式
- 在设置中配置
code.style.settings.url(URL 或本地路径)。
- 按需启用各语言格式化开关:
code.style.format.enable.java
code.style.format.enable.javascript
code.style.format.enable.typescript
code.style.format.enable.html
code.style.format.enable.jsp
code.style.format.enable.jspx
code.style.format.enable.vue
code.style.format.enable.php
全文格式化与选区格式化
全文格式化
- 使用 VS Code 命令 Format Document(或命令 Code Style: Format Document)。
- 扩展会基于
code.style.settings.url 对整个文件进行格式化。
选区格式化
- 先选中代码,再执行 VS Code 命令 Format Selection。
- 扩展仅格式化选中内容。
- Java 选区按语句模式格式化;JS/TS/HTML/JSP/JSPX/Vue 选区按对应语言流程格式化。
VSIX 安装说明
- 安装或更新 VSIX 后,扩展会弹出提示,建议点击 Reload Window(重新加载窗口),以便立即应用本地化信息。
- 若未立即刷新,也可手动执行命令:Developer: Reload Window。
English
This extension formats code using the Eclipse formatter XML configured by code.style.settings.url (can be exported from IntelliJ IDEA).
Usage
- Set
code.style.settings.url (URL or local path).
- Enable formatting toggles for the languages you need:
code.style.format.enable.java
code.style.format.enable.javascript
code.style.format.enable.typescript
code.style.format.enable.html
code.style.format.enable.jsp
code.style.format.enable.jspx
code.style.format.enable.vue
code.style.format.enable.php
Whole Document vs Selected Range
VSIX installation note
- After installing/updating via VSIX, the extension prompts you to click Reload Window so localization updates apply immediately.
- If not refreshed yet, run Developer: Reload Window manually.
Development
- Build the bundled Java formatter runtime once:
- Compile the extension:
| |