vscode 优化配置

2025-03-19 48℃
  1. 打开 VSCode。
  2. 按下快捷键 Ctrl + Shift + P(Windows/Linux)或 Cmd + Shift + P(Mac)。
  3. 在弹出的命令面板中输入 "Preferences: Open Settings (JSON)",有User(个人推荐),WorkSpace,Defeat三个级别。
  4. 选择并按下回车键,即可打开 settings.json 文件。

在json中视自己的需求添加相应配置项

 

{
  // 重新设定tabsize
  "editor.tabSize": 2,
  //在保存文件时自动执行
  "editor.codeActionsOnSave": {
        //每次保存时整理导入语句,通常指重新排列以提高可读性。
        "source.organizeImports": "always",
        //对导入语句进行排序,可能按模块名称或来源文件的顺序排列。
        "source.sortImports": "always",
        //识别并自动添加缺失的TypeScript导入项,确保所有使用了但未声明的模块都能正确引入。
        "source.addMissingImports.ts": "always",
        //移除代码中不再使用的导入语句,保持代码简洁。
        "source.removeUnusedImports": "always"
  },
  // #值设置为true时,每次保存的时候自动格式化;
  "editor.formatOnSave": false,
  // 在使用搜索功能时,将这些文件夹/文件排除在外
  "search.exclude": {
      "**/node_modules": true,
      "**/bower_components": true,
      "**/target": true,
      "**/logs": true,
  }, 
  // 这些文件将不会显示在工作空间中
  "files.exclude": {
      "**/.git": true,
      "**/.svn": true,
      "**/.hg": true,
      "**/CVS": true,
      "**/.DS_Store": true,
      "**/*.js": {
          "when": "$(basename).ts" //ts编译后生成的js文件将不会显示在工作空中
      },
      "**/node_modules": true
  }, 
}

标签: 教程分享

非特殊说明,本博所有文章均为博主原创。