1. Vscode安装
Visual studio code是微软发布的一个运行于 Mac OS X、Windows和 Linux 之上的,针对于编写现代 Web 和云应用的跨平台源代码编辑器。第一种方式是从VScode官网下载.deb文件,然后双击该文件会打开软件中心进行安装。

另一种方式是通过Terminal进行安装,首先输入下面三条语句安装umake:
sudo add-apt-repository ppa:ubuntu-desktop/ubuntu-make sudo apt-get update sudo apt-get install ubuntu-make
然后通过umake来安装VScode:
umake web visual-studio-code
安装完毕后即可打开VScode,主界面如下:

2. Vscode环境配置
(1)安装c/c++插件
首先通过左边栏的Extension栏目安装C++插件,操作如下图:

(2)建立工程
由于VScode是以文件夹的形式管理工程的,因此我们首先新建一个文件夹,我这里取名叫hello。
然后通过VScode打开此文件夹:
新建main.cpp文件并输入程序:

(3)更改配置文件(launch.json)
点击左侧的Debug按钮,选择添加配置(Add configuration),然后选择C++(GDB/LLDB),将自动生成launch.json文件,具体操作如下:
生成的默认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": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "enter program name, for example ${workspaceFolder}/a.out",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
注意:这里需要将program项的内容改为调试时运行的程序,将其改为










