赛时 VSCode 简明配置教程
zerc

PDF Version

赛时 VSCode 可能不包含任何插件,因此在较短时间内配置好 VSCode 的编译运行指令是很有必要的(虽然我觉得没有任何插件的 VSCode 和 DEV-C++ 基本没有区别)。

在工作文件夹下新建文件夹 .vscode,新建文件 tasks.json

运行程序时可以从同目录下的 sample.in 读入数据并输出到 sample.out

可将 .exe 替换为 ${fileBasenameNoExtension}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"version": "2.0.0",
"tasks": [
{
"label": "build",
"type": "shell",
"command": "cls; g++ '${file}' -std=c++14 -Wall -o .exe"
},
{
"label": "run",
"type": "shell",
"command": "cls; Get-Content ./sample.in | ./.exe > ./sample.out"
},
{
"label": "buildrun",
"type": "shell",
"command": "cls; g++ '${file}' -std=c++14 -Wall -o .exe; Get-Content ./sample.in | ./.exe > ./sample.out"
}
]
}

配置快捷键,shift+numpad_add 设为字体放大,f9 - f11 依次为编译,运行,编译并运行(老 DEV 了)。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
[
{
"key": "shift+numpad_add",
"command": "editor.action.fontZoomIn"
},
{
"key": "shift+numpad_subtract",
"command": "editor.action.fontZoomOut"
},
{
"key": "f9",
"command": "workbench.action.tasks.runTask",
"args": "build"
},
{
"key": "f10",
"command": "workbench.action.tasks.runTask",
"args": "run"
},
{
"key": "f11",
"command": "workbench.action.tasks.runTask",
"args": "buildrun"
}
]

设置自动保存。

1
2
3
{
"files.autoSave": "afterDelay"
}
Powered by Hexo & Theme Keep
Total words 2.8k Unique Visitor Page View