C
launch.json
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "(gdb) 启动","type": "cppdbg","request": "launch",// "program": "输入程序名称,例如 ${workspaceFolder}/a.exe","program": "${fileDirname}\\test.exe","args": [],"stopAtEntry": false,"cwd": "${fileDirname}","environment": [],"externalConsole": false,"MIMode": "gdb",// "miDebuggerPath": "/path/to/gdb","miDebuggerPath": "D:\\Softwares\\mingw64\\bin\\gdb.exe","setupCommands": [{"description": "为 gdb 启用整齐打印","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "将反汇编风格设置为 Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}]}]
}
tasks.json
{"tasks": [{"type": "cppbuild","label": "C/C++: gcc.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\gcc.exe","args": ["-fdiagnostics-color=always","-g",// "${file}","*.c","-o",// "${fileDirname}\\${fileBasenameNoExtension}.exe""${fileDirname}\\test.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}
C++
launch.json
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{"name": "C/C++: g++.exe build and debug active file", // 配置名称,将会在启动配置的下拉菜单中显示"type": "cppdbg", // 配置类型,这里只能为cppdbg"request": "launch", // 请求配置类型,可以为launch(启动)或attach(附加)// "program": "${fileDirname}\\${fileBasenameNoExtension}.exe","program": "${fileDirname}\\test.exe", // 将要进行调试的程序的路径"args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可"stopAtEntry": false, // 设为true时程序将暂停在程序入口处,一般设置为false"cwd": "${fileDirname}", // 调试程序时的工作目录,一般为${workspaceRoot}即代码所在目录"environment": [],"externalConsole": false, // 调试时是否显示控制台窗口,一般设置为true显示控制台"MIMode": "gdb",// "miDebuggerPath": "C:\\msys64\\ucrt64\\bin\\gdb.exe","miDebuggerPath": "D:\\Softwares\\mingw64\\bin\\gdb.exe", // miDebugger的路径,注意这里要与MinGw的路径对应"setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true},{"description": "Set Disassembly Flavor to Intel","text": "-gdb-set disassembly-flavor intel","ignoreFailures": true}],"preLaunchTask": "C/C++: g++.exe build active file" // 调试会话开始前执行的任务,一般为编译程序,c++为g++, c为gcc}]
}
tasks.json
{"tasks": [{"type": "cppbuild","label": "C/C++: gcc.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\gcc.exe","args": ["-fdiagnostics-color=always","-g","*.c","-o","${fileDirname}\\test.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": "build","detail": "调试器生成的任务。"},{"type": "cppbuild","label": "C/C++: g++.exe 生成活动文件","command": "D:\\Softwares\\mingw64\\bin\\g++.exe","args": ["-fdiagnostics-color=always","-g","${file}","-o","${fileDirname}\\${fileBasenameNoExtension}.exe"],"options": {"cwd": "${fileDirname}"},"problemMatcher": ["$gcc"],"group": {"kind": "build","isDefault": true},"detail": "调试器生成的任务。"}],"version": "2.0.0"
}
settings.json
{"files.defaultLanguage": "c", // ctrl+N新建文件后默认的语言"editor.formatOnType": true, // 输入分号(C/C++的语句结束标识)后自动格式化当前这一行的代码"editor.suggest.snippetsPreventQuickSuggestions": false, // clangd的snippets有很多的跳转点,不用这个就必须手动触发Intellisense了"editor.acceptSuggestionOnEnter": "off", // 我个人的习惯,按回车时一定是真正的换行,只有tab才会接受Intellisense// "editor.snippetSuggestions": "top", // (可选)snippets显示在补全列表顶端,默认是inline"code-runner.runInTerminal": true, // 设置成false会在“输出”中输出,无法输入"code-runner.executorMap": {"c": "gcc '$fileName' -o '$fileNameWithoutExt.exe' -Wall -O2 -m64 -lm -static-libgcc -fexec-charset=GBK -D__USE_MINGW_ANSI_STDIO && &'./$fileNameWithoutExt.exe'","cpp": "g++ '$fileName' -o '$fileNameWithoutExt.exe' -Wall -O2 -m64 -static-libgcc -fexec-charset=GBK && &'./$fileNameWithoutExt.exe'"// "c": "gcc $fileName -o $fileNameWithoutExt.exe -Wall -O2 -m64 -lm -static-libgcc -fexec-charset=GBK -D__USE_MINGW_ANSI_STDIO && $dir$fileNameWithoutExt.exe",// "cpp": "g++ $fileName -o $fileNameWithoutExt.exe -Wall -O2 -m64 -static-libgcc -fexec-charset=GBK && $dir$fileNameWithoutExt.exe"}, // 右键run code时运行的命令;未注释的仅适用于PowerShell(Win10默认)和pwsh,文件名中有空格也可以编译运行;注释掉的适用于cmd(win7默认)、PS和bash,但文件名中有空格时无法运行"code-runner.saveFileBeforeRun": true, // run code前保存"code-runner.preserveFocus": true, // 若为false,run code后光标会聚焦到终端上。如果需要频繁输入数据可设为false"code-runner.clearPreviousOutput": false, // 每次run code前清空属于code runner的终端消息,默认false"code-runner.ignoreSelection": true, // 默认为false,效果是鼠标选中一块代码后可以单独执行,但C是编译型语言,不适合这样用"code-runner.fileDirectoryAsCwd": true, // 将code runner终端的工作目录切换到文件目录再运行,对依赖cwd的程序产生影响;如果为false,executorMap要加cd $dir"C_Cpp.clang_format_sortIncludes": true, // 格式化时调整include的顺序(按字母排序)
}
C#
launch.json
{// 使用 IntelliSense 了解相关属性。 // 悬停以查看现有属性的描述。// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387"version": "0.2.0","configurations": [{// Use IntelliSense to find out which attributes exist for C# debugging// Use hover for the description of the existing attributes// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md"name": ".NET Core Launch (console)", // 配置名称"type": "coreclr", // 配置类型(编程环境)"request": "launch", // 请求配置类型,可以是launch启动或attach附加"preLaunchTask": "build", // 调试会话开始前执行的任务,一般为编译程序。与tasks.json的label相对应// If you have changed target frameworks, make sure to update the program path."program": "${workspaceFolder}/csharp/test/bin/Debug/net8.0/test.dll", // 需要更改文件路径 将要进行调试的程序的路径"args": [], // 程序调试时传递给程序的命令行参数,一般设为空即可"cwd": "${workspaceFolder}/csharp", // 需要更改路径 调试程序时的工作目录// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console"console": "internalConsole", // “控制台”设置控制目标应用程序启动到哪个控制台(终端)窗口 internalConsole:内部控制台 integratedTerminal:内部终端 externalTerminal:外部终端"stopAtEntry": false // 设为true时程序将暂停在程序入口处,我一般设置为true},{"name": ".NET Core Attach","type": "coreclr","request": "attach"}]
}
settings.json
{"update.showReleaseNotes": false,"update.enableWindowsBackgroundUpdates": false,"update.mode": "none","code-runner.runInTerminal": true,"code-runner.executorMap": {"javascript": "node","java": "cd $dir && javac $fileName && java $fileNameWithoutExt","c": "cd $dir && gcc $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","zig": "zig run","cpp": "cd $dir && g++ $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","objective-c": "cd $dir && gcc -framework Cocoa $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","php": "php","python": "python -u","perl": "perl","perl6": "perl6","ruby": "ruby","go": "go run","lua": "lua","groovy": "groovy","powershell": "powershell -ExecutionPolicy ByPass -File","bat": "cmd /c","shellscript": "bash","fsharp": "fsi","csharp": "cd $dir && dotnet run $fileName","vbscript": "cscript //Nologo","typescript": "ts-node","coffeescript": "coffee","scala": "scala","swift": "swift","julia": "julia","crystal": "crystal","ocaml": "ocaml","r": "Rscript","applescript": "osascript","clojure": "lein exec","haxe": "haxe --cwd $dirWithoutTrailingSlash --run $fileNameWithoutExt","rust": "cd $dir && rustc $fileName && $dir$fileNameWithoutExt","racket": "racket","scheme": "csi -script","ahk": "autohotkey","autoit": "autoit3","dart": "dart","pascal": "cd $dir && fpc $fileName && $dir$fileNameWithoutExt","d": "cd $dir && dmd $fileName && $dir$fileNameWithoutExt","haskell": "runghc","nim": "nim compile --verbosity:0 --hints:off --run","lisp": "sbcl --script","kit": "kitc --run","v": "v run","sass": "sass --style expanded","scss": "scss --style expanded","less": "cd $dir && lessc $fileName $fileNameWithoutExt.css","FortranFreeForm": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran-modern": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran_fixed-form": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","fortran": "cd $dir && gfortran $fileName -o $fileNameWithoutExt && $dir$fileNameWithoutExt","sml": "cd $dir && sml $fileName","mojo": "mojo run"}
}
配置VSCode及运行C#文件
vscode 安装插件 vscode-solution-explorer
安装C#语言 @id:ms-dotnettools.csharp
安装.net后
cmd dotnet --version dotnet -h
code . 在当前工作目录中启动VSCode
新建目录,将目录添加到vscode中
dotnet new console -o test 新建应用控制台应用,名称为test
输入命令dotnet run运行一直报错: Unable to find fallback package folder
NuGet.Packaging.Core.PackagingException: 无法找到回退包文件夹“D:\Softwares\Microsoft Visual Studio\Shared\NuGetPackages
解决,删除NuGet文件夹
C:\Program Files (x86)\NuGet\Config\Microsoft.VisualStudio.FallbackLocation.config
并在扩展中添加Nuget Package Manager
快捷键
ctrl+shift+Y 打开调试控制台
+P 打开上方工作区 可以新建项目
+X 打开扩展
task.json 为编译文件
launch.json 为调试文件 设置调试配置文件
setting.json
{
"update.showReleaseNotes": false,
"update.enableWindowsBackgroundUpdates": false,
"update.mode": "none",
"code-runner.runInTerminal": true,
添加 code-runner.executorMap,回车后自动添加大量内容
}
找到csharp,将scripts 改为 cd $dir && dotnet run $fileName
配置后,安装run code后,直接可以执行 ctrl+alt+N,运行Program.cs文件
如果bin文件夹中没有生成exe文件,在xxx.csproj中添加 <RuntimeIdentifier>win10-x64</RuntimeIdentifier>