vscode 配置

Posted 旭日初扬

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vscode 配置相关的知识,希望对你有一定的参考价值。

目录

一、C++配置

1.1、launch.json

1.2、tasks.json

1.3、cs.cpp

二、C语言配置

1、test.c

1.2、launch.json

1.3、tasks.json


一、C++配置

1.1、launch.json


    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
            "name": "g++.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "$fileDirname\\\\$fileBasenameNoExtension.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "$workspaceFolder",
            "environment": [],
            "externalConsole": true,    //注意此处如果不为true,不会有黑色弹窗
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\\\mingw64\\\\bin\\\\gdb.exe",  //你的mingw路径
            "setupCommands": [
                
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                
            ],
            "preLaunchTask": "g++"  //修改此项
        
    ]

1.2、tasks.json


	"version": "2.0.0",
	"tasks": [
		
			"type": "shell",
			"label": "g++",  //同 luanch.json  "preLaunchTask" 配置一样
			"command": "D:\\\\mingw64\\\\bin\\\\g++.exe",
			"args": [
				"-g",
				"$file",
				"-o",
				"$fileDirname\\\\$fileBasenameNoExtension.exe"
			],
			"options": 
				"cwd": "$workspaceFolder"
			,
			"problemMatcher": [
				"$gcc"
			],
			"group": "build"
		
	]

1.3、cs.cpp

#include <iostream>
using namespace std;
 
void mult(int num) 
	int i, j;
	for (i = 1; i <= num; ++i) 
		for (j = i; j <= num; ++j) 
			cout << i << " * " << j << " = " << i * j << "\\t";
		
		cout << endl;
	
 

 
int main(void) 
	int num =9;
	mult(num);
	system("pause");
	return 0;

二、C语言配置

1、test.c

#include "stdio.h"
void main()

    printf("\\n Hello world \\n");
    system("pause");

1.2、launch.json


    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        
            "name": "gcc.exe - 生成和调试活动文件",
            "type": "cppdbg",
            "request": "launch",
            "program": "$fileDirname\\\\$fileBasenameNoExtension.exe",
            "args": [],
            "stopAtEntry": false,
            "cwd": "$fileDirname",
            "environment": [],
            "externalConsole": true,
            "MIMode": "gdb",
            "miDebuggerPath": "D:\\\\mingw64\\\\bin\\\\gdb.exe",
            "setupCommands": [
                
                    "description": "为 gdb 启用整齐打印",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                
            ],
            "preLaunchTask": "gcc"
        
    ]

1.3、tasks.json


    "tasks": [
        
            "type": "cppbuild",
            "label": "gcc",
            "command": "D:\\\\mingw64\\\\bin\\\\gcc.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"

注意:调试程序时,需要返回到主函数页面,在点击程序执行按钮

 

以上是关于vscode 配置的主要内容,如果未能解决你的问题,请参考以下文章

VSCode自定义代码片段11——vue路由的配置

#VSCode保存插件配置并使用 gist 管理代码片段

VSCode 配置 用户自定义代码片段 自定义自动代码补充

配置 VScode 编辑器 (前端篇)

[vscode]--HTML代码片段(基础版,reactvuejquery)

VS Code配置markdown代码片段