vscode配置C/C++

· · 个人记录

VSCode配置

配置 cl 编译器

  1. 下载 vs2022,如果已经下载,可以跳过这步,
  2. 使用vs2022创建一个项目,或者打开一个c++项目,确保可以使用vs2022正确运行项目
  3. 在项目中找到 vs所用的头文件路径和库文件路径
  4. 编辑环境变量INCLUDE 和 LIB 填充 vs所用的头文件路径和库文件路径
  5. 找到 vs的cl.exe 将其添加到Path 变量中
{
    "code-runner.executorMap": {
        "cpp" : "if (!(Test-Path -Path \"$workspaceRoot\\bin\")){mkdir \"$workspaceRoot\\bin\" | Out-Null} && cl /EHsc /nologo /std:c++20 /Fe$workspaceRoot\\bin\\$fileNameWithoutExt.exe /Fo\"$workspaceRoot\\bin\\$fileNameWithoutExt.obj\" $fullFileName && start Pauser $workspaceRoot\\bin\\$fileNameWithoutExt.exe ",
        "c" : "if (!(Test-Path -Path \"$workspaceRoot\\bin\")){mkdir \"$workspaceRoot\\bin\" | Out-Null} && cl /EHsc /nologo /std:c17 /Fe$workspaceRoot\\bin\\$fileNameWithoutExt.exe /Fo\"$workspaceRoot\\bin\\$fileNameWithoutExt.obj\" $fullFileName && start Pauser $workspaceRoot\\bin\\$fileNameWithoutExt.exe "
    }
}
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: cl.exe 生成活动文件",
            "command": "cl.exe",
            "args": [
                "/Zi",
                "/EHsc",
                "/nologo",
                // "/Fe${fileDirname}\\${fileBasenameNoExtension}.exe",
                "/Fe${workspaceFolder}\\bin\\${fileBasenameNoExtension}.exe",
                "/Fo${workspaceFolder}\\bin\\${fileBasenameNoExtension}.obj",
                "/Fd${workspaceFolder}\\bin\\${fileBasenameNoExtension}.pdb",
                "/Fd${workspaceFolder}\\bin\\${fileBasenameNoExtension}.vc140.pdb",
                "${file}"
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$msCompile"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "调试器生成的任务。"
        }
    ],
    "version": "2.0.0"
}

java 开发环境(jdk 和 jre)

python 环境

​ 官网

​ 速度慢可以选择这个镜像

我的setting josn

{
  "files.autoSave": "afterDelay", //自动保存
  "files.autoSaveDelay": 100, //自动保存时间
  "editor.renderWhitespace": "all", // 显示空白符
  "editor.mouseWheelZoom": true, // 按住ctrl键使用鼠标滚轮改变字体大小  // 
  "editor.quickSuggestions": { //设置快捷补全的开启
    "other": "on",
    "comments": "on",
    "strings": "off"
  },
  "emmet.includeLanguages": { //在默认不受支持的语言中启用emts的缩写
    "javascript": "javascriptreact",
    "vue": "html",
    // "javascript": "html",
    "html":"javascript"
  },
  "files.autoGuessEncoding": true, //自动猜测字符集
  "editor.guides.bracketPairs": true,//开启括号匹配线
  "editor.guides.indentation": true, 
  "workbench.iconTheme": "vscode-icons",   //使用vscode-icons图标(需要安装插件)
  "terminal.integrated.fontFamily": "JetBrainsMono Nerd Font", //设置终端字体(需要安装字体)
  //SSSaSaSaSa   验证等宽字体
  //流俩个日期
  "editor.fontFamily": "'Ubuntu Mono Nerd Font', '等距更纱黑体 SC'", // 设置字体(需要安装字体)
  "terminal.integrated.enableMultiLinePasteWarning": false, // 禁止多行粘贴警告
  "editor.suggest.preview": true, //设置快捷建议
  "editor.tokenColorCustomizations": { // 设置部分字体倾斜
    "textMateRules": [  
      {
        "scope": [  //设置范围
          // "comment",
          // "function",
          // "entity.name.function",
          // "entity.name.method",
          "keyword.control"
        ], //设置风格
        "settings": {
          // "fontStyle": "italic",
          "fontStyle": "italic"
        }
      },{
        "scope":[
          // "entity.name.function",
          // "entity.name.class"
        ],
        "settings": {
          "fontStyle": "bold"
        }
      }
    ]
  },
  "editor.formatOnPaste": true, // 设置粘贴的代码格式化
  "java.debug.settings.showStaticVariables": true, //设置调试在本地变量中显示静态变量
  "java.silentNotification": true, // 控制是否可以使用通知来报告进度。
  "errorLens.gutterIconsEnabled": true, //使错误信息的字体为斜体(个人喜好)
  "workbench.colorCustomizations": { //自定义颜色
    // "editor.hoverHighlightBackground": "#ff0000",
    "editor.background": "#272a30",
    "sideBar.background": "#292b2e",
    "activityBar.activeBackground": "#245a04",
    "activityBar.background": "#1f2122",
    "statusBar.background": "#245a04",
    "menubar.selectionBackground": "#245a04",
    "foreground": "#bff1d8",
    "menu.selectionBackground": "#245a04",
    "titleBar.activeBackground": "#2b2d31",
    "menu.background": "#373a31e1",
    "sideBarSectionHeader.background": "#535353",
    "editor.lineHighlightBackground": "#0e4a074e",
    "terminal.tab.activeBorder": "#148716ae",
    "panelTitle.activeBorder": "#148716ae",
    // "peekViewTitleLabel.foreground": "#ff0000",
    "tab.activeBackground": "#14871660",
    "tab.activeBorder": "#ffffff",
    "quickInputList.focusBackground": "#148716ae",
    "panel.border": "#d7bcbc91",
    // "panelSection.border": "#ff0000",
    "editorLineNumber.activeForeground": "#148716",
    "editorLineNumber.foreground": "#f1e6e63e",
    "panel.background": "#2c2e2dc3",
    // "editorWidget.border": "#b9bece",
    "editor.lineHighlightBorder": "#ffffff86",  //光标所在行四周边框的颜色
    "sideBar.border": "#d7bcbc91",  //侧边栏边框
    "editorGroup.border": "#d7bcbc91",
    "terminal.background": "#25292c"
  },

  "cSpell.diagnosticLevel": "Hint",
  "cSpell.customDictionaries": {
    "custom-dictionary-user": {
      "name": "custom-dictionary-user",
      "path": "~/.cspell/custom-dictionary-user.txt",
      "addWords": true,
      "scope": "user"
    }
  },
     // 下面的太多了懒得注释了
    "diffEditor.codeLens": true,

    "files.defaultLanguage": "cpp", // ctrl+N新建文件后默认的语言
    "editor.formatOnType": true, // 输入时就进行格式化,默认触发字符较少,分号可以触发
    "editor.snippetSuggestions": "top", // snippets代码优先显示补全
    "code-runner.saveFileBeforeRun": true, // run code前保存
    "code-runner.preserveFocus": false, // 若为false,run code后光标会聚焦到终端上。如果需要频繁输入数据可设为false
    "code-runner.clearPreviousOutput": false, // 每次run code前清空属于code runner的终端消息
    "C_Cpp.clang_format_sortIncludes": false, // 格式化时调整include的顺序(按字母排序),这个别开,不信以后遇到问题你就会来关了
    "C_Cpp.intelliSenseEngine": "Default", // 可以为Default或Tag Parser,后者较老,功能较简单。具体差别参考cpptools扩展文档
    "C_Cpp.errorSquiggles": "Disabled", // 因为有clang的lint,所以关掉
    "C_Cpp.autocomplete": "Disabled", // 因为有clang的补全,所以关掉
    "clang.completion.enable": true,
    "C_Cpp.dimInactiveRegions": false,
    "clangd.detectExtensionConflicts": false,
    "terminal.integrated.defaultProfile.windows": "PowerShell", //设置默认的shell
    "[html]": {
      "editor.defaultFormatter": "vscode.html-language-features"
    },
    "editor.stickyScroll.enabled": true,
    "editor.tabCompletion": "on",
    "editor.guides.bracketPairsHorizontal": true,
    "code-runner.runInTerminal": true, // 设置成false会在“输出”中输出,无法输入
    "code-runner.executorMap": {
      "cpp": "cd $dir && g++ $fullFileName -static-libgcc -std=c++14 -fexec-charset=GBK -o \"$fileNameWithoutExt.exe\" && start Pauser .\\$fileNameWithoutExt.exe",
      "c": "cd $dir && gcc $fullFileName -static-libgcc -fexec-charset=GBK -o \"$fileNameWithoutExt.exe\" && start Pauser .\\$fileNameWithoutExt.exe",  
      // "python": " cls && cd /d $dir && python3 -u $fullFileName && pause",
      "python": "cd $dir && D:/Python/Python310/python.exe  $fullFileName"
    },
    "[c]": {
      "editor.defaultFormatter": "ms-vscode.cpptools"
    },
    "terminal.integrated.fontSize": 12,
    "window.zoomLevel": -1,
    "varTranslation.translationEngine": "tencent",
    "varTranslation.tencentSecret": "自己,配置",
    "liveServer.settings.donotShowInfoMsg": true,
    "editor.renderLineHighlightOnlyWhenFocus": true,
}