> Pretty Json 插件,用于JSON格式化,默認(rèn)快捷鍵:`Ctrl + Alt + J` #### 1. 安裝 `Pretty Json` 插件 --- **a. 打開命令面板,快捷鍵:`Ctrl + Shift + P`** ![](https://img.itqaq.com/art/content/fbe81c9634bbd0b1dcc98dc57a5e0f9d.png) **b. 輸入 `install`** ![](https://img.itqaq.com/art/content/ddbe66862c778594b32e513dd0660e36.png) **c. 等待一會(huì)、下面停止了會(huì)彈出插件搜索框** ![](https://img.itqaq.com/art/content/38c40abe592ffd10ca2ef1f9c05ce3d2.png) **d. 選中以下插件、雙擊或回車即可開始下載該插件** ![](https://img.itqaq.com/art/content/ceecb588726adf80e84328bb09fd58d8.png) #### 2. 使用快捷鍵格式化json字符串 --- `Ctrl + Alt + J` ```json {"code":0,"msg":"測試"} ``` **格式化后的內(nèi)容** ```json { "code": 0, "msg": "測試" } ``` #### 3. 快捷鍵無效或使用默認(rèn)的快捷鍵不是格式化json字符串,而是打開了創(chuàng)建文件的解決方案 --- **a. 打開快捷鍵設(shè)置** ![](https://img.itqaq.com/art/content/7fa8b368fde1b5aeb4ea51b7827cbb57.png) **b. 添加以下內(nèi)容** ```json [ { "keys": ["ctrl+alt+j"], "command": "pretty_json" }, ] ``` #### 4. 修改插件配置 --- **復(fù)制 `Settings - Default` 文件內(nèi)容粘貼到 `Settings - User`** ![](https://img.itqaq.com/art/content/84e9acdbb4e33989d89cbb366a2a471a.png) **配置項(xiàng)** ```json { "use_entire_file_if_no_selection": true, "indent": 4, "sort_keys": false, "ensure_ascii": false, "line_separator": ",", "value_separator": ": ", "keep_arrays_single_line": false, "max_arrays_line_length": 120, "pretty_on_save": false, "validate_on_save": true, "jq_binary": "jq" } ``` + indent: 縮進(jìn)長度,默認(rèn)為 `2`,我修改成了 `4`