VScode plugins recommended and C / C ++ configuration

 

Here is what I often use VScode plug. Since the plug-in itself has a detailed configuration and presentation, installation and configuration plug-in itself not be explained, only the main function of spending these plug-ins. Specific use is strongly recommended to look at post-installation instructions the plug, most of the problems and settings can be found, not because it is in English directly to search the Internet.

C ++ class

 

 

Both plug-ins can be written in C ++ makes it easier. It has a powerful auto-complete function. About C ++ specific configuration will explain in detail below.

beautify

Themes and icons I recommend using the following two plug-ins. First Material Theme plugin mainly to change the background color, font and syntax highlighting. The second paragraph of plug-ins can make the icons file structure clearer. Chinese Chinese plug-configured Required.

 

 

 

 

 

 

git

I recommend using gitlens. gitlens incredibly powerful, just the tip of the iceberg icon its function, it can even show a part of who change the code to do at what time.

 

 

tab function expansion

tabout plug can be made out directly from the bracket tab key or click quotes, no need to press the direction key or the end key.

 

 

cmake

cmake function such CMakeLists.txt writing becomes easy, with automatic completion and highlighting.

 

 

 

C / C ++ configuration

Whether it is Linux or Windows, user profiles are placed in .vscode. Explain here the user configuration and the global configuration. A user profile is for a special project or folder and do. All configuration files are placed .vscode hidden files in the folder in the folder.

 

 

Global configuration is as shown in FIG inlet. Here all configuration changes will be visible in any file folder.

 

 

Windows

Paste the first configuration, after the explanations for each file.

c_cpp_properties.json configuration is as follows:

{
    "configurations": [
        {
            "name": "MinGW",
            "compilerPath": "C:\\MinGW\\bin\\g++.exe",
            "includePath": [
                "${workspaceFolder}"
            ],
            "defines": [],
            "browse": {
                "path": [
                    "${workspaceFolder}"
                ],
                "limitSymbolsToIncludedHeaders": true,
                "databaseFilename": ""
            },
            "cStandard": "c11",
            "cppStandard": "c++17"
        }
    ],
    "version": 4
}

  

launch.json:

Https://github.com/Microsoft/vscode-cpptools/blob/master/launch.md // 
{ 
    "Version": "0.2.0", 
    "Configurations": [ 
        { 
            "name": "(GDB) the Launch" // configuration name will appear in the drop-down menu to start the configuration of the 
            "type": "cppdbg", // type of configuration, this can only be cppdbg 
            "request": "launch", // request configuration type, which can be launch (start) or attach (additional) 
            paths "$ {fileDirname} / $ { fileBasenameNoExtension} .exe", // the program to be debugged: "program" 
            "args": [], // passed to debugging command line parameters, usually set to be empty 
            "stopAtEntry": false, // set to true when the program will be suspended at the entrance to the program, I generally set to true 
            "CWD": "$ {workspaceFolder}",// working directory when debugging program // working directory when debugging program 
            "environment": [], // ( environment variables?)
            "externalConsole": true, // whether to display the console window when debugging is generally set to true display console
            "internalConsoleOptions": "neverOpen", // If you do not set neverOpen, will jump to the debugger "Debugging Console" tab, you should not need to manually enter the gdb command, right? 
            "MIMode": "gdb", // specify debugger connection may gdb or lldb. But lldb in the windows is not pre-compiled version. 
            "miDebuggerPath": "gdb.exe", // debugger path suffix can not be omitted under Windows, Linux, then remove the 
            "preLaunchTask": tasks performed before the start of "build" // debugging session, usually the compiler. The label and corresponding tasks.json 
        } 
    ] 
}

  

setting.json:

{
    "files.associations": {
        "iostream": "cpp"
    }
}

  

tasks.json:

Https://code.visualstudio.com/docs/editor/tasks // 
{ 
    "Version": "2.0.0", 
    "Tasks": [ 
        { 
            "label": "Build", // task name, and launch. the corresponding preLaunchTask json 
            "command": "g ++" , // the compiler to use 
            "args": [ 
                "-g", // build and debug information relating to 
                "File $ {}", 
                "-o", // specify the output file name, without the argument, the default output a.exe, a.out default under Linux 
                "$ \\ $ {} {fileDirname fileBasenameNoExtension} .exe", 
                // "$ {fileDirname} / {$ fileBasenameNoExtension .exe} ", 
            ], // compile command parameter 
            " type ":" shell ",Process // shell or may be, corresponds to the former and then enter a command to open the shell, which is directly run command 
            "group": {
                "kind": "Build",
             }
                "isDefault": true // set to false to do a tasks.json configure multiple compiler directives, need to make changes to this document, I have not much to mention here 
            }, 
            "problemMatcher": { 
                "owner": "$ gcc", 
                "FileLocation": "Absolute", 
                "pattern": [ 
                    { 
                        "regexp": "^: (\\ D +): (\\ D +): (*.) \\ S + (warning | error): \\ S + ( . *) $ ", 
                        " File ": 1, 
                        " Line ": 2, 
                        " column ": 3, 
                        //" LOCATION ": 2, 
                        " the Message ":5
                    }
                ]
        }
    ]
}

  

Linux

launch.json

{ 
    // use IntelliSense understanding of the relevant property. 
    // hover to see the existing property description. 
    // For more information, please visit: https://go.microsoft.com/fwlink/?linkid=830387 
    "Version": "0.2.0", 
    "the Configurations": [ 
        { 
            "name": "Build gcc and Debug Active File ", 
            " type ":" cppdbg ", 
            " Request ":" Launch ", 
            " Program ":" $ {fileDirname} / $ {fileBasenameNoExtension} ", 
            " args ": [], 
            " stopAtEntry ": to false , 
            "CWD": "workspaceFolder $ {}", 
            "Environment": [], 
            "
                    "description": "Enable pretty-printing for gdb",
                    "text": "-enable-pretty-printing",
                    "ignoreFailures": true
                }
            ],
            "preLaunchTask": "gcc build active file",
            "miDebuggerPath": "/usr/bin/gdb"
        }
    ]
}

  

tasks.json

{
// 有关 tasks.json 格式的文档,请参见
    // https://go.microsoft.com/fwlink/?LinkId=733558
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "gcc build active file",
            "command": "/usr/bin/gcc",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}",
                "-l",
                "pthread"
​
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ]
        }
    ]
}

  

Configuration instructions

Under normal circumstances, debug process c ++ is that, first of vscode call launch.json, launch.json according to "preLaunchTask": "gcc build active file",the name of the call, called "gcc build active file"task.json of task.json can have multiple task, according to the tasks of the label name to call the corresponding task. The main task is responsible compiled into an executable file. If you only need to generate an executable file, press crtl+shift+bcan be.

c_cpp_properties mainly specialized configurations for c / c ++ compiler, such as include paths.

It is strongly recommended to see the json in English, its description is very easy to understand. The process of c ++ compiler for Linux-based somewhat anyone can quickly grasp and private custom.

See detailed vscode configure Microsoft . Microsoft is strongly recommended to see the docs explain, although it looks reading time-consuming, but far more than you search the Internet all kinds of information more quickly. Because even if you successfully set up, in accordance with my configuration when applied to different projects or language, it may be difficult to configure.

Guess you like

Origin www.cnblogs.com/harrypotterjackson/p/11432252.html