vscode自动换行格式很怪怎么办
比如它把我的这一串代码变成了图二的样子
在原先程序基础下会生成.vscode
文件夹,主要有三个文件
c_cpp_properties.json
:编译路径和智能感知设置tasks.json
:生成程序操作launch.json
:调试设置配置项的信息如下
• version:版本号,不用修改
• configurations:数组类型,用来配置 每一项调试任务的具体配置信息
• type:调试环境的具体类型 node、java、cppdbg 等等
• name:调试任务的名称,用与在下拉列表中展示
• program:启动文件的路径,对于该路径中的变量,下面在介绍
• request:调试模式,一共有两种模式,launch:和应用一起启动,attach:应用已经启动了,但是又想在不重新启动的情况下调试该应用,就可以把调试器附加到应用上
• runtimeExecutable:应用程序执行的时候的执行期,默认是 node,应该为决定路径或者添加到 PATH 路径上的
• console:启动调试终端的位置,一般都 3 个值,如果你的打印信息出现在终端上,不能很好的查看对应变量值可以调整这个值internalConsole:VS Code 的调试控制台,integratedTerminal:VS Code 的集成终端,externalTerminal:VS Code 外部的集成终端
• env:对象,程序启动是传递的环境变量
• args:程序启动是传递的参数
• cwd:程序启动是的跟目录配置
• window:为 window 平台单独设置配置项
• linux:为 linux 平台单独设置配置项
• osx:为 Mac OS 平台单独设置配置项
常见变量
• ${workspaceFolder}:项目文件夹在 VS Code 中打开的路径
• ${file}:当前开打开(激活)的文件
• ${relativeFile}:相对于 {workspaceFolder} 的文件路径
• ${fileBasename}:当前打开文件的名称
• ${fileBasenameNoExtension}:当前打开文件的名称,不带扩展名的
• ${fileExtname}:当前打开文件的扩展名
• ${fileDirname}:当前打开文件的文件夹名称
task.json
的设置
Terminal > Configure Default Build Task 默认的g++task.json
如下
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "C/C++: gcc build active file",//任务名称,和launch.json中的preLaunchTask必须相同
"command": "/usr/bin/gcc",// 终端命令
//"command": "D:\\mingw64\\mingw64\\bin\\g++.exe",//windows平台下按照路径设置
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}"
],// 终端命令附加参数
"options": {
"cwd": "/usr/bin"
},
"problemMatcher": [
"$gcc"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
默认launch.json
的默认设置
{
// 使用 IntelliSense 了解相关属性。
// 悬停以查看现有属性的描述。
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "gcc-7 build and debug active file",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}/${fileBasenameNoExtension}",
"args": [],// 调试时传递给程序的参数
"stopAtEntry": false,// 调试时是否停在程序入口:{true:是,false:否}
"cwd": "${workspaceFolder}",// 工作目录
"environment": [],/ 额外的环境变量
"externalConsole": false,// true:输出到外部终端;false:只输出到软件终端(有显示不全的可能)
"MIMode": "gdb",
"setupCommands": [
{
"description": "为 gdb 启用整齐打印",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "gcc-7 build active file",// 预编译任务名称,和tasks.json中的label必须相同
"miDebuggerPath": "/usr/bin/gdb"
//"miDebuggerPath": "D:\\mingw64\\mingw64\\bin\\gdb.exe",//windows平台下按照路径设置
}
]
}
默认的c_cpp_properties.json
设置
{
"configurations": [
{
"name": "Linux",
"includePath": ["${workspaceFolder}/**"],
"defines": [],
"compilerPath": "/usr/bin/gcc",
// "compilerPath": "D:\\mingw64\\mingw64\\bin\\g++.exe",//windows平台下按照路径设置
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "clang-x64"
}
],
"version": 4
}
文件处于预览模式有个标识,就是标题栏的文件名称是斜体的.
如何关闭?在设置文件里设置 workbench.editor.enablePreview 为 false 即可,这是全局设置的,每次都是打开新 tab。
(NoPermissions (FileSystemError): Error: EACCES: permission denied
目前看都说是权限问题。
取消C/C++ Extension: 正在下载 2/4: ClangFormat (Linux / x86_64)
目前看需要直接安装vsix文件,但下载不下来