vs code常用配置settings.json
一、editor编辑器设置
{
"editor.tabSize": 4, // 设置 Tab 键的宽度为 4 个空格
"editor.defaultFormatter": null, // 默认格式化工具
"editor.formatOnSave": true, // 每次保存时自动格式化代码
"editor.formatOnPaste": true, // 自动格式化粘贴的内容
"editor.formatOnType": false,// 是否在输入时自动格式化
"editor.fontFamily": "MesloLGS NF", // 设置编辑器的字体为 MesloLGS NF
"editor.fontLigatures": true, // 启用字体连字功能
"editor.fontWeight": "normal", // 设置字体粗细为正常
"editor.fontSize": 12, // 设置字体大小为 12
"editor.lineHeight": 20, // 设置行高为 20
"editor.letterSpacing": 0, // 设置字母间距为 0
"editor.renderLineHighlight": "none", // 不显示当前行的背景高亮
"editor.renderWhitespace": "none", // 不显示空白字符
"editor.rulers": [80, 100, 120], // 在 80、100 和 120 列处显示垂直标尺
"editor.snippetSuggestions": "top", // 将代码片段建议显示在建议列表的顶部
"editor.wordWrap": "on", // 启用自动换行
"editor.detectIndentation": false, // 不自动检测文件的缩进设置
"editor.mouseWheelZoom": true, // 启用鼠标滚轮缩放功能
"editor.multiCursorModifier": "ctrlCmd", // 设置多光标修饰键为 Ctrl/Cmd
"editor.quickSuggestions": { // 控制快速建议的显示
"comments": "off", // 在注释中不显示建议
"strings": "off", // 在字符串中不显示建议
"other": "off" // 在其他位置不显示建议
},
"editor.renderControlCharacters": true, // 显示控制字符
"editor.smoothScrolling": true, // 启用平滑滚动
"editor.wordWrapColumn": 80, // 设置自动换行的列数为 80
"editor.wrappingIndent": "indent", // 设置换行后的缩进方式为与上一行对齐
"editor.accessibilitySupport": "off", // 关闭辅助功能支持
"editor.acceptSuggestionOnEnter": "smart", // 设置按下 Enter 键时智能接受建议
"editor.autoClosingBrackets": "languageDefined", // 根据语言定义自动闭合括号
"editor.bracketPairColorization.enabled": true, // 启用括号对颜色化
"editor.colorDecorators": true, // 启用颜色装饰器
"editor.cursorBlinking": "smooth", // 设置光标闪烁效果为平滑
"editor.cursorStyle": "line", // 设置光标样式为竖线
"editor.cursorSurroundingLines": 3, // 设置光标周围显示的行数为 3
"editor.dragAndDrop": true, // 启用拖放功能
"editor.folding": true, // 启用代码折叠功能
"editor.codeActionsOnSave": { // 保存时执行的代码操作
"source.fixAll.eslint": "always" // 总是使用 ESLint 修复所有问题
},
"editor.guides.indentation": true, // 启用缩进参考线
"explorer.confirmDelete": false, // 禁用删除文件或文件夹时的确认对话框
"explorer.confirmDragAndDrop": false // 禁用拖放文件或文件夹时的确认对话框
}
二、工作台设置
{
"workbench.colorTheme": "One Dark Pro", // 设置工作区的颜色主题为 "One Dark Pro"
"workbench.iconTheme": "file-icons", // 设置工作区的图标主题为 "file-icons"
"workbench.colorCustomizations": {}, // 自定义颜色主题,当前为空对象,表示未进行自定义
"workbench.settings.applyToAllProfiles": [], // 将设置应用到所有配置文件,当前为空数组,表示未应用到任何配置文件
"workbench.settings.settingsSearchTocBehavior": "hide", // 设置设置搜索的目录行为为隐藏
"workbench.settings.editor": "json", // 设置设置编辑器为 JSON 格式
"workbench.settings.openDefaultSettings": false, // 不打开默认设置
"workbench.settings.openDefaultKeybindings": false, // 不打开默认快捷键设置
"workbench.editor.showTabs": "none", // 不显示编辑器标签页
"workbench.editor.tabSizing": "shrink", // 设置编辑器标签页的宽度为自适应缩小
"workbench.editor.highlightModifiedTabs": true, // 高亮显示已修改的标签页
"workbench.editor.labelFormat": "short", // 设置编辑器标签的显示格式为简短格式
"workbench.editor.decorations.colors": true, // 启用编辑器装饰器的颜色
"workbench.editor.decorations.badges": true, // 启用编辑器装饰器的徽章
"workbench.editor.enablePreview": true, // 启用编辑器预览模式
"workbench.editor.enablePreviewFromQuickOpen": true // 启用从快速打开功能中预览文件
}
#三、调试设置
{
"debug.console.fontSize": 14, // 设置调试控制台的字体大小为 14
"debug.console.fontFamily": "MesloLGS NF", // 设置调试控制台的字体为 "MesloLGS NF"
"debug.console.wordWrap": true, // 启用调试控制台的自动换行功能
"debug.console.lineHeight": 1.5, // 设置调试控制台的行高为 1.5 倍
"debug.toolBarLocation": "docked", // 设置调试工具栏的位置为停靠状态
"debug.openExplorerOnEnd": true, // 在调试结束时自动打开资源管理器
"debug.inlineValues": "on", // 在调试时启用内联变量值显示
"debug.showInStatusBar": "never" // 在状态栏中永远不显示调试信息
}
四、文件管理设置
{
"files.autoSave": "afterDelay", // 设置文件自动保存模式为“延迟后保存”
"files.exclude": {
"**/.git": true, // 在资源管理器中隐藏 .git 文件夹
"**/.DS_Store": true // 在资源管理器中隐藏 .DS_Store 文件
},
"files.associations": {
"*.vue": "vue", // 将 .vue 文件关联为 Vue 文件类型
"*.wxml": "xml", // 将 .wxml 文件关联为 XML 文件类型
"*.wxs": "javascript", // 将 .wxs 文件关联为 JavaScript 文件类型
"*.wxss": "css" // 将 .wxss 文件关联为 CSS 文件类型
},
"files.autoSaveDelay": 1000, // 设置自动保存的延迟时间为 1000 毫秒(1 秒)
"files.encoding": "utf8", // 设置文件编码为 UTF-8
"files.eol": "\n", // 设置文件的行尾符为 LF(适用于 Unix/Linux/macOS)
"files.insertFinalNewline": true, // 在文件末尾自动插入空行
"files.trimTrailingWhitespace": true, // 自动删除行尾的空格
"files.watcherExclude": {
"**/.git/objects/**": true, // 忽略 .git/objects 目录的文件变化
"**/.git/subtree-cache/**": true, // 忽略 .git/subtree-cache 目录的文件变化
"**/node_modules/*/**": true // 忽略 node_modules 目录的文件变化
}
}
五、terminal终端设置
{
"terminal.integrated.fontFamily": "MesloLGS NF", // 设置终端字体系列为 "MesloLGS NF"
"terminal.integrated.fontSize": 12, // 设置终端字体大小为 12
"terminal.integrated.fontWeight": "normal", // 设置终端字体粗细为正常
"terminal.integrated.fontWeightBold": "bold", // 设置终端粗体字体的粗细为粗体
"terminal.integrated.cursorStyle": "block", // 设置终端光标样式为块状
"terminal.integrated.defaultProfile.windows": "Command Prompt", // 设置 Windows 系统的默认终端为 "Command Prompt"
"terminal.integrated.defaultProfile.linux": "bash", // 设置 Linux 系统的默认终端为 "bash"
"terminal.integrated.defaultProfile.osx": "zsh", // 设置 macOS 系统的默认终端为 "zsh"
"terminal.integrated.enableVisualBell": false, // 禁用终端的视觉响铃效果
"terminal.integrated.scrollback": 10000, // 设置终端的滚动缓冲区大小为 10000 行
"terminal.integrated.rightClickBehavior": "default", // 设置终端右键点击行为为默认行为
"terminal.integrated.copyOnSelection": true, // 启用选中文本时自动复制到剪贴板
"terminal.integrated.cursorBlinking": true, // 启用终端光标闪烁效果
"terminal.integrated.cursorWidth": 1, // 设置终端光标的宽度为 1
"terminal.integrated.detectLocale": "auto", // 自动检测终端的区域设置
"terminal.integrated.drawBoldTextInBrightColors": true, // 启用粗体文本以亮色显示
"terminal.integrated.mouseWheelScrollSensitivity": 1, // 设置鼠标滚轮滚动灵敏度为 1
"terminal.integrated.sendKeybindingsToShell": true, // 将快捷键绑定发送到终端 shell
"terminal.integrated.tabs.enabled": true, // 启用终端标签页功能
"terminal.integrated.tabs.location": "left", // 设置终端标签页的位置为左侧
"terminal.integrated.lineHeight": 1.6, // 设置终端行高
"terminal.integrated.tabs.showActions": "always", // 始终显示终端标签页的操作按钮
"workbench.colorCustomizations": {
"terminal.foreground": "#00FF00", // 终端字体颜色
"terminal.background": "#000000", // 终端背景颜色
"terminalCursor.foreground": "#FF0000", // 终端光标颜色
"terminalCursor.background": "#FFFFFF", // 终端光标背景颜色
"terminal.ansiBlack": "#000000", // ANSI 黑色
"terminal.ansiBlue": "#0000FF", // ANSI 蓝色
"terminal.ansiCyan": "#00FFFF", // ANSI 青色
"terminal.ansiGreen": "#00FF00", // ANSI 绿色
"terminal.ansiMagenta": "#FF00FF", // ANSI 洋红色
"terminal.ansiRed": "#FF0000", // ANSI 红色
"terminal.ansiWhite": "#FFFFFF", // ANSI 白色
"terminal.ansiYellow": "#FFFF00", // ANSI 黄色
"terminal.ansiBrightBlack": "#808080", // ANSI 亮黑色
"terminal.ansiBrightBlue": "#0000FF", // ANSI 亮蓝色
"terminal.ansiBrightCyan": "#00FFFF", // ANSI 亮青色
"terminal.ansiBrightGreen": "#00FF00", // ANSI 亮绿色
"terminal.ansiBrightMagenta": "#FF00FF", // ANSI 亮洋红色
"terminal.ansiBrightRed": "#FF0000", // ANSI 亮红色
"terminal.ansiBrightWhite": "#FFFFFF", // ANSI 亮白色
"terminal.ansiBrightYellow": "#FFFF00" // ANSI 亮黄色
}
}
六、扩展设置
{
// 是否启用扩展自动更新
"extensions.autoUpdate": true,
// 是否启用扩展推荐
"extensions.ignoreRecommendations": false,
}
七、语言特定设置
{
// Java 设置
"[java]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.defaultFormatter": "redhat.java"
},
// C++ 设置
"[cpp]": {
"editor.tabSize": 4,
"editor.insertSpaces": true,
"editor.defaultFormatter": "xaver.clang-format"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[css]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[less]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[jsonc]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[scss]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[vue]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[json]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
}