VSC 设置相关
文章目录

VSC 设置方法

  • Command Open Settings 以打开设置 UI
  • Command Open Settings (JSON) 可以直接打开配置文件

快捷键

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
[
{
"key": "ctrl+shift+r",
"command": "workbench.action.quickOpen"
},
{
"key": "ctrl+p",
"command": "-workbench.action.quickOpen"
},
{
"key": "ctrl+d",
"command": "editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "ctrl+shift+k",
"command": "-editor.action.deleteLines",
"when": "textInputFocus && !editorReadonly"
},
{
"key": "f12",
"command": "git.revertSelectedRanges"
},
{
"key": "ctrl+shift+b",
"command": "bookmarks.toggle",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+k",
"command": "-bookmarks.toggle",
"when": "editorTextFocus"
},
{
"key": "f3",
"command": "bookmarks.jumpToNext",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+l",
"command": "-bookmarks.jumpToNext",
"when": "editorTextFocus"
},
{
"key": "shift+f3",
"command": "bookmarks.jumpToPrevious",
"when": "editorTextFocus"
},
{
"key": "ctrl+alt+j",
"command": "-bookmarks.jumpToPrevious",
"when": "editorTextFocus"
},
{
"key": "ctrl+shift+d",
"command": "bookmarks.clear"
},
{
"key": "ctrl+shift+e",
"command": "bookmarks.editLabel"
},
{
"key": "ctrl+down",
"command": "editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+down",
"command": "-editor.action.copyLinesDownAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+up",
"command": "editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+up",
"command": "-editor.action.copyLinesUpAction",
"when": "editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+l",
"command": "workbench.action.gotoLine"
},
{
"key": "ctrl+g",
"command": "-workbench.action.gotoLine"
},
{
"key": "shift+alt+d",
"command": "eslint.executeAutofix"
},
{
"key": "ctrl+alt+j",
"command": "editor.action.joinLines"
},
{
"key": "alt+x",
"command": "editor.action.toggleWordWrap"
},
{
"key": "alt+z",
"command": "-editor.action.toggleWordWrap"
},
{
"key": "ctrl+alt+x",
"command": "revealFileInOS",
"when": "!editorFocus"
},
{
"key": "shift+alt+r",
"command": "-revealFileInOS",
"when": "!editorFocus"
},
{
"key": "shift+alt+f shift+alt+s",
"command": "editor.action.formatSelection",
"when": "editorHasDocumentSelectionFormattingProvider && editorHasDocumentSelectionFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "ctrl+k ctrl+f",
"command": "-editor.action.formatSelection",
"when": "editorHasDocumentSelectionFormattingProvider && editorHasDocumentSelectionFormattingProvider && editorTextFocus && !editorReadonly"
},
{
"key": "shift+alt+f",
"command": "-editor.action.formatDocument.none",
"when": "editorTextFocus && !editorHasDocumentFormattingProvider && !editorHasDocumentFormattingProvider && !editorReadonly"
},
{
"key": "shift+alt+f",
"command": "editor.action.formatDocument.none"
},
{
"key": "shift+alt+f",
"command": "editor.action.format"
}
]

Extensions

  • JS Quick Console
  • All AutoComplete
  • Auto Close tag
  • Beautify
  • SFTP
  • Bookmarks
  • ESLint
  • Expand selection To Scope
  • indent-rainbow
  • Bracket Pair Colorizer
  • Markdown-formatter
    • Markdown 工具, 主要用于格式整理。
  • vscode-pangu
    • Markdown 工具, 主要用于中英文之间添加空格。
  • Markdown All in One
    • Markdown 工具, 主要用于生成 TOC
    • 对于 TOC, 需要到设置里面加一行 markdown.extension.toc.downcaseLink: true , 让所有的 TOC 生成都变成小写, 这样可以和 Hexo 的设置相同
  • MaterialTheme
  • Paste and Indent
  • TODO Highlight

总体设置

关闭默认预览模式

一般从 Sidebar 点开一个文件是预览模式, 可以看到 Tab 文字是斜体的

这个时候打开另一个文件的话不会开启新的 Tab

要默认打开新窗口只需要在 Setting.json 里面设置

1
"workbench.editor.enablePreview": false,

字体设置

如果字体间有空格, ** 不需要使用单引号 **

或者直接到配置文件里面设置:

1
2
3
4
5
6
7
8
9
10
11
// Main editor
"editor.fontSize": 18,
// Terminal panel
"terminal.integrated.fontSize": 14,
// Output panel
"[Log]": {
"editor.fontSize": 15
},
"window.zoomLevel": 5,
"editor.fontFamily": "Fira Code",
"editor.fontLigatures": true

自动保存与格式化

1
2
3
4
5
6
7
8
9
10
11
"files.autoSave": "afterDelay"

"editor.formatOnSave": true

"editor.formatOnPaste": true

"editor.tabSize": 4

"editor.insertSpaces": true

"editor.renderWhitespace": "all"

语言特定设置

1
2
3
"[languageid]": {

}

搜索 / 搜索结果筛选 / File to include/exclude

单次搜索设置

1
node_modules/*,build/*

全局设置

设置完后搜索的时候记得要把这个按钮给选上, 点击一下就可以了

*/** 代表当前文件夹以及所有的子文件夹

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
"files.exclude": {
"*/**/node_modules/": true,
"wp-includes/": true,
"wp-admin/": true,
//"wp-*.*": true,
"wp-config.*": false,
"xmlrpc.php": true,
".vscode/": true,
"*/**/cache/": true,
"*/**/uploads/": true,
"*/**/infinitewp/": true,
"*/**/.github/": true,
//"*/**/build/": true
},
"search.exclude": {
"build/": true,
},

特殊要求: 仅显示特定文件夹

其实这个地方将所有的都给忽略掉, 然后将其中一个给取消忽略了

1
2
3
4
5
6
7
{
"files.exclude":
{
"**/*": true,
"**/Scripts": false
}
}

ESLint: Fix on save

需要注意的是这个地方其实是设置 editor 的 code action on save

setting.json:

1
2
3
4
5
6
{
"editor.codeActionsOnSave": {
"source.fixAll.eslint": true
},
//"eslint.validate": ["javascript"]
}