当前位置: 首页 > news >正文

vscode 使用说明

在这里插入图片描述

文章目录

  • 1、文档
  • 2、技巧
    • 显示与搜索
    • 宏定义和包含头文件
  • 3、插件
  • 4、智能编写
  • 5、VSCode 与 C++
    • (1)安装
    • (2)调试
      • (a)使用 CMake 进行跨平台编译与调试
      • (b)launch.json
      • (c)传参

1、文档

官网
官网帮助文档
VSCode 精品教程

2、技巧

显示与搜索

Glob Patterns Reference

   VS Code 支持以下 glob 语法:

  • / 分隔路径段
  • * 匹配路径段中的零个或多个字符
  • ? 匹配路径段中的一个字符
  • ** 匹配任意数量的路径段,包括无
  • {} 对条件进行分组(例如 {**/*.html,**/*.txt} 匹配所有 HTML 和文本文件)
  • [] 声明要匹配的字符范围(example.[0-9] 匹配 example.0,example.1 … )
  • [!...] 否定要匹配的字符范围(example.[!0-9] 匹配 example.a、example.b,但不匹配 example.0 )

   注意:在 Windows 上使用的是 / 来分隔路径而不是 \ 。VS Code 中的 Glob 模式需要 / 分隔路径,但它们都会在路径上 /\ 路径内匹配。


   .vscode/settings.jsonfiles.exclude 控制文件显示,search.exclude 控制搜索 。

{"files.exclude": {"**/*.a.cmd": true,"**/*.order.cmd": true,"**/*.o.cmd": true,"**/*.o.d": true,// "**/*.o": true,".github": true,"arch/[^a]*": true,"arch/a[^r]*": true,"arch/arc": true,"arch/arm": true,"drivers/[^pu]*": true,"drivers/p[^c]*": true,"drivers/pcmcia": true,"drivers/u[^s]*": true,"**/.git": true,"**/.svn": true,"**/.hg": true,"**/CVS": true,"**/.DS_Store": true,"**/Thumbs.db": true,"**/*.crswap": true},"search.exclude": {"**/node_modules": true,"**/bower_components": true,"**/*.code-search": true},"files.associations": {"memory_resource": "c"}
}

VScode全局搜索屏蔽、显示屏蔽指定文件类型及文件夹

在这里插入图片描述

宏定义和包含头文件

   .vscode/c_cpp_properties.jsondefines 控制宏定义,includePath 控制头文件搜索 。

{"configurations": [{"name": "Linux","includePath": ["${workspaceFolder}/**"],"defines": ["CONFIG_PCI","CONFIG_USB_XHCI_DBGCAP","MODULE"],"compilerPath": "/usr/bin/gcc","cStandard": "c17","cppStandard": "gnu++17","intelliSenseMode": "linux-gcc-x64"}],"version": 4
}

vscode添加宏定义
VSCode#include头文件时找不到头文件:我的解决方法

3、插件

使用VScode运行C/C++,你可能要安装这些插件

VScode如何屏蔽不需要的文件及添加搜索的头文件路径
搜索栏语法_vscode files.exclude_一颗不甘坠落的流星的博客-CSDN博客
vscode工程屏蔽不需要的文件(保持搜索便利)_vscode排除文件夹_蓁蓁啊的博客-CSDN博客

vsCode离线安装remote-ssh插件和搭建远程开发环境 - 爱码网

vscode调试时以16进制查看变量_vscode调试查看变量_虔诚的学习者的博客-CSDN博客

简单的 VSCode 插件离线安装方法_乘风破浪kk的博客-CSDN博客

VSCode使用IDEA快捷键,IntelliJ IDEA Keybindings插件使用方法

在这里插入图片描述

VSCode 中文乱码设置

4、智能编写

VScode 使用之自动生成文件注释_vscode自动生成注释_会打莎士比亚的猴子的博客-CSDN博客
Doxygen与Vscode操作全解_51CTO博客_vscode使用
Vscode 插件 DoxyGen Documentation Generator C语言详细设置_doxygen vscode
C/C++工程的文档自动生成工具
Visual Studio Code(VScode)自动生成头文件

5、VSCode 与 C++

(1)安装

C++ programming with Visual Studio Code

    Visual Studio Code 的 C/C++ 支持由Microsoft C/C++ 扩展提供,以在 Windows、Linux 和 macOS 上实现跨平台 C 和 C++ 开发。

安装插件

  1. 打开 VS 代码。

  2. 选择活动栏上的扩展视图图标或使用键盘快捷键 ( Ctrl+Shift+X )。

  3. 搜索’C++'。
    在这里插入图片描述

  4. 选择安装。

(2)调试

(a)使用 CMake 进行跨平台编译与调试

Get started with CMake Tools on Linux
vscode-cmake-tools/README.md at main · microsoft/vscode-cmake-tools · GitHub
Visual Studio Code Variables Reference
用VSCode和CMake编写调试C/C++ - 简书
vscode+cmake下debug报错Target debugging is no longer supported with the legacy driver

(b)launch.json

  • gdb
{"version": "0.2.0","configurations": [{"name": "(gdb) Launch","type": "cppdbg","request": "launch",// Resolved by CMake Tools:"program": "${command:cmake.launchTargetPath}","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [{// add the directory where our target was built to the PATHs// it gets resolved by CMake Tools:"name": "PATH","value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"},{"name": "OTHER_VALUE","value": "Something something"}],"console": "externalTerminal","MIMode": "gdb","setupCommands": [{"description": "Enable pretty-printing for gdb","text": "-enable-pretty-printing","ignoreFailures": true}]}]
}
  • msvc
{"version": "0.2.0","configurations": [{"name": "(msvc) Launch","type": "cppvsdbg","request": "launch",// Resolved by CMake Tools:"program": "${command:cmake.launchTargetPath}","args": [],"stopAtEntry": false,"cwd": "${workspaceFolder}","environment": [{// add the directory where our target was built to the PATHs// it gets resolved by CMake Tools:"name": "PATH","value": "${env:PATH}:${command:cmake.getLaunchTargetDirectory}"},{"name": "OTHER_VALUE","value": "Something something"}],"console": "externalTerminal"}]
}

(c)传参

vscode + cmake命令行参数debug_cmake 命令行 参数_wakaka_Yu的博客-CSDN博客
如何在vscode中将命令行参数传递给cmake?-腾讯云开发者社区-腾讯云

   .vscode/settings.jsoncmake.debugConfig 控制传参 。命令行参数 -code 8 配置如下:

{"cmake.debugConfig": {"args": ["-code","8"]}
}

  
 

http://www.lryc.cn/news/507374.html

相关文章:

  • 【Linux系统编程】:信号(2)——信号的产生
  • Android Studio AI助手---Gemini
  • 【day09】面向对象——静态成员和可变参数
  • Android学习(七)-Kotlin编程语言-Lambda 编程
  • 彻底认识和理解探索分布式网络编程中的SSL安全通信机制
  • 【libuv】Fargo信令2:【深入】client为什么收不到服务端响应的ack消息
  • Vue3自定义事件
  • BeautifulSoup 与 XPath 用法详解与对比
  • Emacs 折腾日记(五)——elisp 数字类型
  • 重拾设计模式--外观模式
  • 源码编译llama.cpp for android
  • StarRocks 排查单副本表
  • Windows11 家庭版安装配置 Docker
  • 线程知识总结(二)
  • 解决vscode ssh远程连接服务器一直卡在下载 vscode server问题
  • 【Cadence射频仿真学习笔记】IC设计中电感的分析、建模与绘制(EMX电磁仿真,RFIC-GPT生成无源器件及与cadence的交互)
  • Definition of Done
  • 【漏洞复现】CVE-2023-37461 Arbitrary File Writing
  • 简单工厂模式和策略模式的异同
  • HuggingFace datasets - 下载数据
  • 梯度(Gradient)和 雅各比矩阵(Jacobian Matrix)的区别和联系:中英双语
  • Vscode搭建C语言多文件开发环境
  • 自定义 C++ 编译器的调用与管理
  • 时间管理系统|Java|SSM|JSP|
  • 用SparkSQL和PySpark完成按时间字段顺序将字符串字段中的值组合在一起分组显示
  • Sentinel 学习笔记3-责任链与工作流程
  • Latex 转换为 Word(使用GrindEQ )(英文转中文,毕业论文)
  • 使用Chat-LangChain模块创建一个与用户交流的机器人
  • 国家认可的人工智能从业人员证书如何报考?
  • 【网络云计算】2024第51周-每日【2024/12/17】小测-理论-解析