iFluxArt

博客导航友链
© 2025 iFluxArt 保留所有权利
目录
基础配置
用户设置 (settings.json)
必备插件
代码质量和格式化
开发效率插件
前端开发插件
主题和图标
快捷键配置
自定义快捷键 (keybindings.json)
代码片段配置
JavaScript/TypeScript 片段
工作区配置
项目级配置 (.vscode/settings.json)
推荐插件配置 (.vscode/extensions.json)
调试配置
launch.json 配置
性能优化
提升 VS Code 性能
团队协作
共享配置
Git 集成
常用命令
命令面板常用命令
快捷操作
故障排除
常见问题解决
重置配置
相关资源
分类
标签
品牌案例科技品牌快捷键中英对照表术语对照汽车品牌食品饮料服装文案运动品牌读书笔记广告理论办公软件文案美妆护肤视频剪辑部署最佳实践广告文案电商零售创意金融支付写作GitnpmCSS动画代码质量HTMLReactJavaScript组件开发静态站点剧本写作电影创作创作指南真人秀WindowsAcrobatAfter EffectsAuditionIllustratorLightroomMedia EncoderPhotoshopPremiere ProFinal Cut Pro设计工具直播电商私域运营运营策略私域流量DeepSeek运维GeminiCLIGoogle AI配置指南提示词工程AI交互MetaPayEasy亚马逊京东字节跳动滴滴百度网易美团腾讯阿里巴巴IBM思科甲骨文佳能大疆尼康科大讯飞AppleGoogleHTCOPPOrealmevivo一加三星华为小米微软索尼联想荣耀魅族招聘小鹏特斯拉理想蔚来CELEBRITYMISSOSEOK baby步履不停丰田奔驰奥迪宝马本田唯品会拼多多AMD惠普戴尔英伟达英特尔兰蔻完美日记雅诗兰黛谐音梗安踏李宁耐克阿迪达斯微信支付支付宝伊利农夫山泉可口可乐星巴克百事可乐大卫·奥格威教程威廉·伯恩巴克路克·苏立文约瑟夫·休格曼标题技巧版本控制工作流程VS Code开发环境插件配置Docker容器化GitHubSSH包管理pnpmTailwind CSS动画库Python规范工程实践Markdown语法对比动画工具前端开发CSSFAQ编程基础Web框架项目管理Astro评论系统GitHub集成React组件Hexo静态博客主题开发HugoGo语言Next.js技术栈VitePressVue3文档站点开发指南Monorepo剧本结构动态结构悬念设计叙事技巧人物设计戏剧冲突导演思维写作技巧结局设计故事创作电影节国际电影电影奖项电视节目综艺节目探险节目电视制作电影结构剧作分析影像构成电影分析精神分析叙事研究经典台词诗意台词中国电影Cloudflare网络安全VPNNVIDIA显卡驱动AI工具Obsidian插件知识管理V2rayN代理工具网络配置鼠标设置注册表修改显示设置高分屏Lightroom ClassicFCP邀请码内测PDF工具动画制作音频编辑照片处理视频编码Keynote演示软件ExcelPowerPointWordWPS剪映微信公众号账号注册平台认证抖音小店店铺运营电商运营抖音运营账号定位内容策略运营思维商业策略数据驱动人货场直播间运营直播合规违禁词平台规则直播带货运营流程直播脚本话术模板直播技巧运营指南微信生态内容创作行业分类成功案例方法论商业价值变现模式会员运营用户分层商业变现Waves音频插件混音制作
相关文章

将 Monorepo 中的 Packages 发布到 npm 的完整指南

Google Python 编码规范指南

开发最佳实践

Next.js 技术栈推荐清单与最佳实践

React 核心库详解

VS Code 开发环境配置

2025年4月16日
8345 字
预计阅读 34 分钟

Visual Studio Code 是目前最受欢迎的代码编辑器之一。本指南将帮助您配置一个高效的开发环境。

基础配置

用户设置 (settings.json)

JSON
{
  // 编辑器基础设置
  "editor.fontSize": 14,
  "editor.fontFamily": "'Fira Code', 'Cascadia Code', Consolas, monospace",
  "editor.fontLigatures": true,
  "editor.lineHeight": 1.5,
  "editor.tabSize": 2,
  "editor.insertSpaces": true,
  "editor.wordWrap": "on",
  "editor.minimap.enabled": false,
  "editor.renderWhitespace": "boundary",
  
  // 代码格式化
  "editor.formatOnSave": true,
  "editor.formatOnPaste": true,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.organizeImports": true
  },
  
  // 文件和工作区
  "files.autoSave": "afterDelay",
  "files.autoSaveDelay": 1000,
  "files.trimTrailingWhitespace": true,
  "files.insertFinalNewline": true,
  "files.exclude": {
    "**/node_modules": true,
    "**/.git": true,
    "**/.DS_Store": true,
    "**/dist": true,
    "**/build": true
  },
  
  // 终端设置
  "terminal.integrated.fontSize": 13,
  "terminal.integrated.fontFamily": "'Fira Code', monospace",
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  
  // 工作台外观
  "workbench.colorTheme": "One Dark Pro",
  "workbench.iconTheme": "material-icon-theme",
  "workbench.startupEditor": "newUntitledFile",
  "workbench.editor.enablePreview": false,
  
  // Git 设置
  "git.enableSmartCommit": true,
  "git.confirmSync": false,
  "git.autofetch": true,
  
  // 语言特定设置
  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[typescript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[json]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode"
  },
  "[markdown]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.wordWrap": "on"
  }
}

必备插件

代码质量和格式化

Prettier - Code formatter

JSON
// .prettierrc
{
  "semi": true,
  "trailingComma": "es5",
  "singleQuote": true,
  "printWidth": 80,
  "tabWidth": 2,
  "useTabs": false
}

ESLint

JSON
// .eslintrc.js
module.exports = {
  extends: [
    'eslint:recommended',
    '@typescript-eslint/recommended',
    'prettier'
  ],
  plugins: ['@typescript-eslint'],
  rules: {
    'no-console': 'warn',
    'no-unused-vars': 'error',
    '@typescript-eslint/no-explicit-any': 'warn'
  }
};

开发效率插件

  1. Auto Rename Tag - 自动重命名配对标签
  2. Bracket Pair Colorizer 2 - 括号配对着色
  3. Path Intellisense - 路径自动补全
  4. GitLens - Git 增强功能
  5. Thunder Client - API 测试工具
  6. Live Server - 本地服务器
  7. Code Spell Checker - 拼写检查

前端开发插件

  1. ES7+ React/Redux/React-Native snippets - React 代码片段
  2. Auto Import - ES6, TS, JSX, TSX - 自动导入
  3. Tailwind CSS IntelliSense - Tailwind 智能提示
  4. CSS Peek - CSS 类定义跳转
  5. HTML CSS Support - HTML 中的 CSS 支持

主题和图标

  1. One Dark Pro - 流行的暗色主题
  2. Material Icon Theme - 文件图标主题
  3. Dracula Official - 另一个优秀的暗色主题

快捷键配置

自定义快捷键 (keybindings.json)

JSON
[
  // 快速打开终端
  {
    "key": "ctrl+`",
    "command": "workbench.action.terminal.toggleTerminal"
  },
  
  // 快速切换侧边栏
  {
    "key": "ctrl+b",
    "command": "workbench.action.toggleSidebarVisibility"
  },
  
  // 快速打开命令面板
  {
    "key": "ctrl+shift+p",
    "command": "workbench.action.showCommands"
  },
  
  // 快速文件搜索
  {
    "key": "ctrl+p",
    "command": "workbench.action.quickOpen"
  },
  
  // 多光标选择
  {
    "key": "ctrl+d",
    "command": "editor.action.addSelectionToNextFindMatch"
  },
  
  // 代码格式化
  {
    "key": "shift+alt+f",
    "command": "editor.action.formatDocument"
  },
  
  // 快速注释
  {
    "key": "ctrl+/",
    "command": "editor.action.commentLine"
  }
]

代码片段配置

JavaScript/TypeScript 片段

JSON
// javascript.json
{
  "Console Log": {
    "prefix": "clg",
    "body": [
      "console.log('$1:', $1);"
    ],
    "description": "Console log with label"
  },
  
  "Arrow Function": {
    "prefix": "af",
    "body": [
      "const $1 = ($2) => {",
      "  $3",
      "};"
    ],
    "description": "Arrow function"
  },
  
  "React Component": {
    "prefix": "rfc",
    "body": [
      "import React from 'react';",
      "",
      "interface ${1:Component}Props {",
      "  $2",
      "}",
      "",
      "export function $1({ $3 }: ${1:Component}Props) {",
      "  return (",
      "    <div>",
      "      $4",
      "    </div>",
      "  );",
      "}"
    ],
    "description": "React functional component with TypeScript"
  },
  
  "useState Hook": {
    "prefix": "us",
    "body": [
      "const [$1, set${1/(.*)/${1:/capitalize}/}] = useState($2);"
    ],
    "description": "useState hook"
  },
  
  "useEffect Hook": {
    "prefix": "ue",
    "body": [
      "useEffect(() => {",
      "  $1",
      "}, [$2]);"
    ],
    "description": "useEffect hook"
  }
}

工作区配置

项目级配置 (.vscode/settings.json)

JSON
{
  "typescript.preferences.importModuleSpecifier": "relative",
  "typescript.suggest.autoImports": true,
  "typescript.updateImportsOnFileMove.enabled": "always",
  
  "emmet.includeLanguages": {
    "javascript": "javascriptreact",
    "typescript": "typescriptreact"
  },
  
  "search.exclude": {
    "**/node_modules": true,
    "**/dist": true,
    "**/.next": true,
    "**/coverage": true
  },
  
  "files.watcherExclude": {
    "**/node_modules/**": true,
    "**/.git/objects/**": true,
    "**/.git/subtree-cache/**": true,
    "**/dist/**": true
  }
}

推荐插件配置 (.vscode/extensions.json)

JSON
{
  "recommendations": [
    "esbenp.prettier-vscode",
    "dbaeumer.vscode-eslint",
    "bradlc.vscode-tailwindcss",
    "ms-vscode.vscode-typescript-next",
    "formulahendry.auto-rename-tag",
    "ms-vscode.vscode-json",
    "eamodio.gitlens",
    "rangav.vscode-thunder-client",
    "ritwickdey.liveserver",
    "streetsidesoftware.code-spell-checker"
  ]
}

调试配置

launch.json 配置

JSON
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Next.js: debug server-side",
      "type": "node-terminal",
      "request": "launch",
      "command": "npm run dev"
    },
    {
      "name": "Next.js: debug client-side",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:3000"
    },
    {
      "name": "Debug Jest Tests",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/node_modules/.bin/jest",
      "args": ["--runInBand"],
      "console": "integratedTerminal",
      "internalConsoleOptions": "neverOpen"
    }
  ]
}

性能优化

提升 VS Code 性能

JSON
{
  // 禁用不必要的功能
  "editor.minimap.enabled": false,
  "editor.hover.enabled": false,
  "editor.lightbulb.enabled": false,
  "editor.parameterHints.enabled": false,
  
  // 限制文件监控
  "files.watcherExclude": {
    "**/node_modules/**": true,
    "**/.git/**": true,
    "**/dist/**": true,
    "**/build/**": true
  },
  
  // 搜索优化
  "search.followSymlinks": false,
  "search.useIgnoreFiles": true,
  
  // TypeScript 优化
  "typescript.disableAutomaticTypeAcquisition": true,
  "typescript.suggest.enabled": false
}

团队协作

共享配置

创建团队共享的配置文件:

Bash
# 项目结构
.vscode/
├── settings.json      # 项目设置
├── extensions.json    # 推荐插件
├── launch.json       # 调试配置
└── tasks.json        # 任务配置

Git 集成

JSON
// .vscode/settings.json
{
  "git.decorations.enabled": true,
  "git.enableStatusBarSync": true,
  "git.showPushSuccessNotification": true,
  "gitlens.codeLens.enabled": true,
  "gitlens.currentLine.enabled": true,
  "gitlens.hovers.enabled": true
}

常用命令

命令面板常用命令

  • Ctrl+Shift+P - 打开命令面板
  • Developer: Reload Window - 重新加载窗口
  • Preferences: Open Settings (JSON) - 打开设置文件
  • Extensions: Show Recommended Extensions - 显示推荐插件
  • Git: Clone - 克隆仓库
  • Terminal: Create New Integrated Terminal - 创建新终端

快捷操作

  • Ctrl+Shift+E - 文件资源管理器
  • Ctrl+Shift+F - 全局搜索
  • Ctrl+Shift+G - Git 面板
  • Ctrl+Shift+D - 调试面板
  • Ctrl+Shift+X - 插件面板

故障排除

常见问题解决

  1. 插件冲突:禁用可疑插件,逐个启用测试
  2. 性能问题:检查文件监控设置,排除大型目录
  3. 格式化问题:检查 Prettier 和 ESLint 配置
  4. TypeScript 错误:重启 TypeScript 服务器
  5. Git 问题:检查 Git 路径配置

重置配置

Bash
# 重置用户设置
rm -rf ~/.vscode/User/settings.json

# 重置插件
code --list-extensions | xargs -L 1 echo code --uninstall-extension

相关资源

  • 终端工具和命令行优化
  • 调试工具和技巧
  • 开发效率工具集
  • Git 工作流程指南
版权声明

本文为作者原创文章,遵循 CC BY-NC-ND 4.0 协议。

  • 署名:转载时请注明出处
  • 非商业性使用:禁止商业用途
  • 禁止演绎:不得修改原文
查看完整许可证