【VSCode】Visual Studio Code使用方法

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环境配置

问题列表:

  1. 问题: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指定环境变量
stopAtEntryC++ 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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值