VS Code settings. json 配置项大全
以下是 VS Code 的 settings.json 配置项完整指南,按功能分类整理:
🏠 基础设置
{
// 文件相关
"files.autoSave": "afterDelay", // 自动保存:off, afterDelay, onFocusChange, onWindowChange
"files.autoSaveDelay": 1000, // 自动保存延迟(毫秒)
"files.hotExit": "onExit", // 热退出:onExit, onExitAndWindowClose
"files.defaultLanguage": "", // 新建文件的默认语言
"files.encoding": "utf8", // 文件编码
"files.eol": "\n", // 行尾符:\n, \r\n, auto
// 窗口相关
"window.title": "${dirty}${activeEditorShort}${separator}${rootName}${separator}${appName}",
"window.zoomLevel": 0, // 窗口缩放级别
"window.restoreWindows": "all", // 启动时恢复窗口:all, none, one
"window.newWindowDimensions": "default", // 新窗口尺寸:default, inherit, offset, maximized
// 更新相关
"update.mode": "default", // 更新模式:default, none, start, manual
}
🎨 外观与主题
{
// 主题与颜色
"workbench.colorTheme": "Default Dark+",
"workbench.iconTheme": "vs-seti",
"workbench.productIconTheme": "Default",
// 界面布局
"workbench.startupEditor": "welcomePage", // 启动时显示:welcomePage, newUntitledFile, readme
"workbench.sideBar.location": "left", // 侧边栏位置:left, right
"workbench.activityBar.visible": true, // 显示活动栏
"workbench.statusBar.visible": true, // 显示状态栏
// 编辑器外观
"editor.minimap.enabled": true, // 启用缩略图
"editor.scrollBeyondLastLine": true, // 滚动超出最后一行
"editor.renderLineHighlight": "all", // 行高亮:all, gutter, line, none
"editor.lineNumbers": "on", // 行号:on, off, relative, interval
// 字体设置
"editor.fontFamily": "Consolas, 'Courier New', monospace",
"editor.fontSize": 14,
"editor.fontLigatures": false, // 字体连字
"editor.fontWeight": "normal",
// 自定义颜色
"workbench.colorCustomizations": {
"editor.background": "#1e1e1e",
"editor.foreground": "#d4d4d4",
"statusBar.background": "#007acc"
}
}
✏️ 编辑器行为
{
// 光标与选择
"editor.cursorStyle": "line", // 光标样式:block, block-outline, line, line-thin, underline
"editor.cursorBlinking": "blink", // 光标闪烁:blink, smooth, phase, expand, solid
"editor.multiCursorModifier": "alt", // 多光标修饰键:ctrlCmd, alt
// 编辑行为
"editor.tabSize": 4,
"editor.insertSpaces": true, // 用空格代替制表符
"editor.detectIndentation": true, // 自动检测缩进
"editor.trimAutoWhitespace": true, // 自动修剪末尾空格
"editor.autoIndent": "full", // 自动缩进:none, keep, brackets, advanced, full
// 代码折叠
"editor.folding": true, // 启用代码折叠
"editor.foldingStrategy": "auto", // 折叠策略:auto, indentation
"editor.showFoldingControls": "mouseover", // 折叠控件:always, mouseover
// 滚动行为
"editor.smoothScrolling": true, // 平滑滚动
"editor.mouseWheelZoom": false, // 鼠标滚轮缩放
"editor.scrollBeyondLastColumn": 5, // 滚动超出最后一列
// 建议与补全
"editor.quickSuggestions": {
"other": true,
"comments": false,
"strings": false
},
"editor.suggestOnTriggerCharacters": true,
"editor.acceptSuggestionOnCommitCharacter": true,
// 括号
"editor.matchBrackets": "always", // 括号匹配:always, near, never
"editor.bracketPairColorization.enabled": true, // 括号对颜色化
}
🔍 搜索设置
{
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.code-search": true,
"**/dist": true,
"**/build": true
},
"search.useIgnoreFiles": true, // 使用.gitignore
"search.useGlobalIgnoreFiles": true, // 使用全局忽略文件
"search.showLineNumbers": true, // 搜索结果显示行号
"search.collapseResults": "auto", // 折叠结果:auto, alwaysCollapse, alwaysExpand
}
📁 文件与文件夹
{
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"**/Thumbs.db": true,
"**/node_modules": true
},
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/.git/subtree-cache/**": true,
"**/node_modules/**": true,
"**/dist/**": true
},
"files.associations": {
"*.js": "javascript",
"*.jsx": "javascriptreact",
"*.ts": "typescript",
"*.tsx": "typescriptreact"
}
}
🎯 语言特定设置
Python
{
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.codeActionsOnSave": {
"source.organizeImports": true
}
},
"python.defaultInterpreterPath": "python",
"python.analysis.autoImportCompletions": true,
"python.analysis.typeCheckingMode": "basic"
}
JavaScript/TypeScript
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.tabSize": 2
},
"typescript.updateImportsOnFileMove.enabled": "always",
"javascript.updateImportsOnFileMove.enabled": "always"
}
HTML/CSS
{
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"html.format.wrapLineLength": 120,
"css.validate": true
}
JSON
{
"[json]": {
"editor.defaultFormatter": "vscode.json-language-features"
},
"json.schemas": [
{
"fileMatch": [
"package.json"
],
"url": "https://json.schemastore.org/package"
}
]
}
🔧 终端设置
{
"terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
"terminal.integrated.shell.linux": "/bin/bash",
"terminal.integrated.shell.osx": "/bin/zsh",
"terminal.integrated.fontSize": 14,
"terminal.integrated.cursorBlinking": true,
"terminal.integrated.cursorStyle": "line",
"terminal.integrated.scrollback": 10000,
"terminal.integrated.copyOnSelection": true,
"terminal.integrated.rightClickBehavior": "default"
}
🛠️ 调试设置
{
"debug.onTaskErrors": "showErrors", // 调试任务错误:showErrors, debugAnyways, prompt
"debug.internalConsoleOptions": "openOnSessionStart", // 内部控制台:neverOpen, openOnSessionStart, openOnFirstSessionStart
"debug.showInStatusBar": "always", // 状态栏调试显示:always, never, onFirstSessionStart
"debug.allowBreakpointsEverywhere": false, // 允许在任何地方设置断点
"debug.openDebug": "openOnSessionStart", // 打开调试视图:openOnSessionStart, openOnFirstSessionStart, neverOpen
}
📦 扩展相关设置
Git
{
"git.enabled": true,
"git.path": null,
"git.autofetch": true,
"git.autofetchPeriod": 180,
"git.confirmSync": true,
"git.openRepositoryInParentFolders": "always"
}
Prettier
{
"prettier.singleQuote": true,
"prettier.semi": true,
"prettier.tabWidth": 2,
"prettier.trailingComma": "es5",
"prettier.printWidth": 100,
"prettier.bracketSpacing": true,
"prettier.jsxBracketSameLine": false
}
ESLint
{
"eslint.enable": true,
"eslint.run": "onType",
"eslint.options": {},
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
]
}
Live Server
{
"liveServer.settings.port": 5500,
"liveServer.settings.root": "/",
"liveServer.settings.CustomBrowser": "chrome",
"liveServer.settings.https": {
"enable": false,
"cert": "",
"key": "",
"passphrase": ""
}
}
⚡ 性能优化设置
{
// 内存与性能
"editor.largeFileOptimizations": true, // 大文件优化
"files.maxMemoryForLargeFilesMB": 4096, // 大文件内存限制
// 渲染优化
"editor.renderControlCharacters": false, // 渲染控制字符
"editor.renderWhitespace": "boundary", // 渲染空白:none, boundary, selection, all
"editor.hideCursorInOverviewRuler": false, // 在概览标尺中隐藏光标
// 文件监视
"files.useExperimentalFileWatcher": false, // 使用实验性文件监视器
"files.watcherExclude": {
"**/.git/objects/**": true,
"**/node_modules/**": true
}
}
🔒 安全设置
{
"security.workspace.trust.enabled": true, // 工作区信任
"security.workspace.trust.untrustedFiles": "open", // 不受信任文件:open, newWindow, prompt
"security.allowedUNCHosts": [], // 允许的UNC主机
"security.allowedExtensionProtocols": {}, // 允许的扩展协议
// 网络相关
"http.proxy": "", // HTTP代理
"http.proxyStrictSSL": true, // 严格SSL验证
"http.proxyAuthorization": null, // 代理认证
}
🎮 键盘快捷键相关
{
"keyboard.dispatch": "code", // 键盘事件分发:code, keyCode
"editor.stickyScroll.enabled": true, // 启用粘性滚动
"editor.occurrencesHighlight": true, // 出现高亮
"editor.selectionHighlight": true, // 选择高亮
}
🌐 国际化设置
{
"locale": "zh-CN", // 界面语言
"editor.unicodeHighlight.ambiguousCharacters": true, // 高亮模糊字符
"editor.unicodeHighlight.invisibleCharacters": true, // 高亮不可见字符
"editor.wordSeparators": "`~!@#$%^&*()-=+[{]}\\|;:'\",.<>/?", // 单词分隔符
}
📊 实验性功能
{
"editor.experimental.pasteActions.enabled": true, // 实验性粘贴操作
"editor.inlineSuggest.enabled": true, // 内联建议
"editor.stickyScroll.enabled": true, // 粘性滚动
"workbench.editor.customLabels.enabled": true, // 自定义编辑器标签
"extensions.experimental.affinity": false, // 扩展亲和性
}
🎪 个性化设置
{
// 自定义状态栏
"workbench.statusBar.feedback.visible": false,
// 自定义标题栏
"window.menuBarVisibility": "default", // 菜单栏可见性:default, visible, toggle, hidden
// 自定义通知
"workbench.enableExperiments": false, // 启用实验
// 自定义工作台
"workbench.editor.showTabs": true, // 显示编辑器标签
"workbench.editor.tabSizing": "fit", // 标签大小:fit, shrink
"workbench.editor.highlightModifiedTabs": true, // 高亮修改的标签
}
📝 完整示例配置
{
// 编辑器基础设置
"editor.fontSize": 14,
"editor.lineHeight": 1.5,
"editor.tabSize": 2,
"editor.insertSpaces": true,
"editor.detectIndentation": true,
// 外观
"workbench.colorTheme": "Default Dark+",
"workbench.iconTheme": "vs-seti",
// 文件与搜索
"files.autoSave": "onFocusChange",
"search.exclude": {
"**/node_modules": true,
"**/dist": true
},
// 语言特定
"[python]": {
"editor.defaultFormatter": "ms-python.python",
"editor.tabSize": 4
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
// 终端
"terminal.integrated.fontSize": 13,
// 扩展设置
"prettier.singleQuote": true,
"eslint.enable": true
}