# 变量命名转换助手 — Variable Conversion (VSCode 扩展)
[Marketplace](https://marketplace.visualstudio.com/items?itemName=coder-xiaomo.variable-conversion) [GitHub](https://github.com/coder-xiaomo/variable-conversion-vscode-extension.git) [Gitee](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension.git)
一个强大的变量命名及路径风格转换插件,支持一键转换、循环转换,支持右键菜单、快捷键、状态栏等多种方式使用。
A powerful variable and path conversion extension. Supports one-key conversion & cyclic conversion. You can use it through the editor menu, shortcut keys and status bar.
> **【近期更新】**
>
> **v2.2.0 (2025-12-05)**
>
> - 支持配置目标转换格式顺序
> - 支持展示当前配置的格式顺序信息弹窗,可显示配置重复项和无效项
> - 支持从弹窗中点击按钮快捷跳转至设置页对应配置项
>
> **v2.1.0 (2025-07-14)**
>
> - 支持仅开启部分目标转换格式 (优化 VSCode 配置项)
>
> **v2.0.0 (2024-12-15)**
>
> - 支持 Windows / Unix 路径风格转换(可选中文本中的路径,然后使用 `Ctrl + Alt + /` 快捷键,或点击右键菜单、底部状态栏路径转换按钮轻松实现转换)
- ✅ 支持多选区 Support multi-selection
- ✅ 支持多窗口 Support subwindow
- ✅ 支持撤回 & 重做 Support undo & redo (Ctrl + Z / Ctrl + Y)
- ✅ 支持仅开启部分目标转换格式 Support enabling only partial target conversion formats
> 🔭 Tips for Chinese users: 如果您无法看到下文图片,请[点这里](https://gitee.com/coder-xiaomo/variable-conversion-vscode-extension/blob/main/README.md)查看
## 如何使用? How to Use?
### 循环转换 Cyclic conversion
选中需要转换的内容,然后按下 `Ctrl + Alt + [` 或 `Ctrl + Alt + ]` 即可前后灵活切换变量命名方式。
Select what you want to convert in the editor, and then press `Ctrl + Alt + [` or `Ctrl + Alt + ]` to flexibly convert variable name flexibly.

### 基础转换 Basic conversion
**1. 选中代码中需要转换的内容** **Select The Text To Convert**

**2. 按 `Shift + Alt + T`** **Press `Shift + Alt + T`**

或者点击状态栏的 `变量转换` 按钮
Or click the `String Conversion` button in the status bar

或者右键 -> `变量转换`
Or right-click -> `String Conversion`

或者右键 -> 将变量转换为...
Or right-click on the selected text -> Convert string to...

**3. 选择转换目标,转换完成** **Select the conversion target and complete**
### 路径转换 Path Conversion (Beta)
> 该功能仍在 Beta 测试阶段,如您在使用过程中遇到问题,欢迎通过文末联系方式进行反馈。
>
> This feature is still in Beta testing stage, if you encounter any problems during use, please give feedback via the contact information at the end of the article.
路径转换与变量转换操作逻辑基本相同,都可以通过 *右键菜单*、*底部状态栏*、*快捷键* 等方式使用,唯一区别是快捷键的不同。
路径转换快捷键为:
- 切换下一个路径风格:`Ctrl + Alt + /`
- 切换上一个路径风格:`Ctrl + Alt + Shift + /`

**注:** 目前 `v2.0.0` 版本暂仅支持 `Windows 风格路径` 与 `Unix 风格路径` 互转,所以这两个快捷键目前效果相同。**后续会陆续增加其他更多路径风格**(例如 `Windows Git Bash` 风格,浏览器 `file://` 协议风格等),敬请期待。
## 快捷键 Shortcut key
| 功能 Feature | 快捷键 shortcut key |
| ------------------------------------------------------------ | ---------------------- |
| 变量转换 快速选择 Variable Conversion QuickPick | Shift + Alt + T |
| 变量循环转换→上一个 Variable Cyclic Conversion → Previous one | Ctrl + Alt + [ |
| 变量循环转换→下一个 Variable Cyclic Conversion → Next one | Ctrl + Alt + ] |
| 显示格式顺序信息弹窗 Show Format Order Info Dialog | Ctrl + Alt + \` |
| 路径转换 快速选择 Path Conversion QuickPick | Shift + Alt + / |
| 路径循环转换→上一个 Path Cyclic conversion → Previous one | Ctrl + Alt + / |
| 路径循环转换→下一个 Path Cyclic conversion → Next one | Ctrl + Shift + Alt + / |
> 若您觉得快捷键使用不顺手,您可在 VSCode 左下角齿轮图标⚙ → 键盘快捷方式中自定义修改快捷键。
## 配置项 Configurations
| 配置项 Configuration Key | 描述 Description | 配置示例 | 默认值 |
| --------------------------------------- | ------------------------------------------------------------ | ----------------------------------------------- | -------- |
| `variable-conversion.enabledFormats` | 配置启用的变量命名方式
Configuration of Enabled Variable Naming Conventions. | `{ "xxxCase.enabled": boolean, ... }` | 见配置项 |
| `variable-conversion.formatOrder` | 配置变量命名方式的显示顺序
Configure the display order of variable naming conventions. | `[ "camel_case", "pascal_case", "snake_case" ]` | 见配置项 |
| `variable-conversion.disablePathFormat` | 定义哪些路径风格是禁用的
Define which path formats are disabled. | `["windows_style", "unix_style"]` | 见配置项 |
配置项如下:
| Enabled Formats 配置 | Format Order 配置 |
![]() |
![]() |
| Disable Path Format 配置 | |
![]() |