VSCode在不同应用下的基本配置
Latex环境配置
Recipes配置
"latex-workshop.latex.recipes": [
{
"name": "latexmk ?",
"tools": [
"latexmk"
]
},
{
"name": "pdflatex ➞ bibtex ➞ pdflatex × 2",
"tools": [
"pdflatex",
"bibtex",
"pdflatex",
"pdflatex"
]
}
,{
"name": "xelatex",
"tools": [
"xelatex"
]
}
,{
"name": "bibtex",
"tools": [
"bibtex"
]
}
,{
"name": "xelatex ➞ bibtex ➞ xelatex x 2",
"tools": [
"xelatex",
"bibtex",
"xelatex",
"xelatex"
]
}
]
,"latex-workshop.latex.tools": [
{
"name": "latexmk",
"command": "latexmk",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"-pdf",
"-outdir=%OUTDIR%",
"%DOC%"
],
"env": {}
},
{
"name": "pdflatex",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
],
"env": {}
},
{
"name": "bibtex",
"command": "bibtex",
"args": [
"%DOCFILE%"
],
"env": {}
}
,{
"name": "xelatex",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"%DOC%"
]
}
],
Python环境配置
问题列表:
问题
:import当前目录自定义的函数文件时,pylint报错,也不能跳转到定义的函数,但是对脚本的运行没有影响。
原因
:目前未查明。
解决方法
:将settings.json中"python.jediEnabled"的值设置为true,使得pylint由Microsoft Python Analysis Engine替换为python jedi。
C环境配置
Debugger配置
配置launch.json
参考链接:Configuring C/C++ debugging。
launch.json
的功能是配置debugger。
配置debugger属性的参数包括:
参数 | 功能 |
---|---|
program (required) | 指定要debug的目标应用的路径和名称 |
配置目标应用的参数包括:
参数 | 功能 |
---|---|
args | 指定目标应用的输入参数 |
cwd | 指定目标应用的工作目录 |
environment | 指定环境变量 |
stopAtEntry | C++ extension默认在main() 的第一行加入断点,当该值为true 时,开启该断点,为false 时,关闭该断点 |
sourceFileMap | 告知GDB程序运行需要的头文件所在路径 |
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/bin/EncoderAppStaticd",
"args": [
"-c", "${workspaceFolder}/../test/encoder_randomaccess_vtm.cfg",
"-c", "${workspaceFolder}/../test/BasketballDrillText.cfg",
"--QP=37",
"--FrameSkip=0",
"--FramesToBeEncoded=49",
"--LIBVCSkipNum=0",
"--LIBVCFrameNum=500"
],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"sourceFileMap": [
{
"/mnt/c": "${env:systemdrive}/",
"/usr/": "/usr/bin"
}
]
}
]
编译配置
配置编译属性
vscode将编译器的属性记录在.vscode/c_cpp_properties.json
中。
参数 | 功能 |
---|---|
compilerPath | 编译器路径,cpptools根据这个编译器去搜索C++ standard library files |
includePath | 指定非当前workspace下的header files路径 |
一个c_cpp_properties.json
示例文件的内容如下:
{
"configurations": [
{
"name": "Win32",
"defines": ["_DEBUG", "UNICODE", "_UNICODE"],
"compilerPath": "/usr/bin/g++",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "${default}",
"browse": {
"path": ["${workspaceFolder}"],
"limitSymbolsToIncludedHeaders": true,
"databaseFilename": ""
}
}
],
"version": 4
}
创建编译任务
tasks.json
文件用于描述如何compile/build该程序。
参数 | 功能 |
---|---|
command | 指定执行该task的程序,例如在linux中是g++ |
args | 指定执行程序的输入参数,参数内容根据command 指定的程序的需求而定 |
label | 表示该task的标记名称,可以自定义 |
windows.options.shell | 指定执行该task配置的bash shell,如果使用默认的bash shell,可以不指定该参数 |
{
"version": "2.0.0",
"windows": {
"options": {
"shell": {
"executable": "bash.exe",
"args": ["-c"]
}
}
},
"tasks": [
{
"label": "build hello world on WSL",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"/home/<your linux user name>/projects/helloworld/helloworld.out",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
执行编译任务
执行tasks.json
定义的编译任务,在command palette中执行Tasks:Run Build Task
。