VSCode无插件基础配置
VSCode 配置文件基础
VSCode 的配置文件主要有三个级别:
- 用户 user:用户全局设置。
- 工作区 workspace:一个工作区可以包含多个文件夹。
- 文件夹 folder:相当于项目级别。譬如 C 语言的项目可以把相应的编译代码加到配置文件中去。
这里主要关注用户级别的配置。它的优先级比后面两个要低,可以放日常操作习惯的配置。它位于$HOME/.config/Code/User/settings.json。
VSCode 为各种类型的配置分了类,缺省值也在网页上罗列了。对于基础配置,主要关注以下几个方面,它们和日常码字关系比较紧密:
- editor
- file
- workbench
- explorer
- search
- terminal
VSCode 也可以为特定的编程语言做特殊的设定。譬如为 typescript 和 markdown 添加配置
{
"[typescript]": {
"editor.formatOnSave": true,
...
}
"[markdown]": {
...
}
}基础配置
以下是当前使用的settings.json的全部内容。其中的字体设置为 JetBrains Mono NF,图标设置为 Material Icon Theme,主题设置为 One Monokai。这些需要安装相应的插件和字体。
{
// editor
"editor.acceptSuggestionOnEnter": "smart",
"editor.autoClosingBrackets": "beforeWhitespace",
"editor.autoClosingDelete": "always",
"editor.autoClosingOvertype": "always",
"editor.autoClosingQuotes": "beforeWhitespace",
"editor.bracketPairColorization.enabled": true,
"editor.cursorBlinking": "expand",
"editor.cursorSmoothCaretAnimation": "on",
"editor.detectIndentation": false,
"editor.fastScrollSensitivity": 10,
"editor.foldingImportsByDefault": true,
"editor.foldingStrategy": "indentation",
"editor.fontFamily": "'JetBrainsMono NF'", // 可以显示Nerd字符
"editor.fontLigatures": true,
"editor.fontSize": 12,
"editor.formatOnPaste": true,
"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.guides.bracketPairs": true,
"editor.insertSpaces": true,
"editor.lineHeight": 1.5,
"editor.linkedEditing": true,
"editor.minimap.enabled": false,
"editor.mouseWheelZoom": true,
"editor.quickSuggestions": {
"comments": "on",
"other": "on",
"strings": "on",
},
"editor.renderControlCharacters": true,
"editor.renderWhitespace": "boundary",
"editor.rulers": [80, 120], // 在第80以及第120字符处显示一条线
"editor.smoothScrolling": true,
"editor.stickyScroll.enabled": true,
"editor.stickyTabStops": true,
"editor.suggest.insertMode": "replace",
"editor.suggest.snippetsPreventQuickSuggestions": false,
"editor.suggestSelection": "recentlyUsedByPrefix",
"editor.tabCompletion": "on",
"editor.tabSize": 4,
"editor.wordBasedSuggestions": "off",
"editor.wordSeparators": "`~!@%^&*()=+[{]}\\|;:'\",.<>/?(),。;:", // 遇到列出字符不断行
"editor.wordWrap": "wordWrapColumn", // 超过88列显示在第二行
"editor.wordWrapColumn": 88,
"editor.wrappingIndent": "indent",
// explorer
"explorer.compactFolders": true,
"explorer.copyRelativePathSeparator": "/",
// files
"files.autoGuessEncoding": true,
"files.autoSave": "onFocusChange",
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true,
"files.trimTrailingWhitespace": true,
// search
"search.exclude": {
"**/.DS_Store": true,
"**/.git": true,
"**/.gitignore": true,
"**/.idea": true,
"**/.svn": true,
"**/.vscode": true,
"**/build": true,
"**/dist": true,
"**/node_modules": true,
"**/package-lock.json": true,
"**/pnpm-lock.yaml": true,
"**/tmp": true,
"**/yarn.lock": true,
},
"search.followSymlinks": false,
"search.searchEditor.singleClickBehaviour": "peekDefinition",
// telemetry
"telemetry.telemetryLevel": "error",
"terminal.integrated.fontFamily": "'JetBrainsMono NF'",
// terminal
"terminal.integrated.gpuAcceleration": "on",
"terminal.integrated.stickyScroll.enabled": true,
"terminal.integrated.suggest.enabled": true,
// window
"window.dialogStyle": "custom",
// workbench
"workbench.colorTheme": "One Monokai",
"workbench.iconTheme": "material-icon-theme",
"workbench.list.fastScrollSensitivity": 10,
"workbench.list.smoothScrolling": true,
"workbench.startupEditor": "none",
"workbench.tree.enableStickyScroll": true,
}