欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > vscode 使用说明

vscode 使用说明

2025/2/25 10:12:03 来源:https://blog.csdn.net/Liuqz2009/article/details/144559069  浏览:    关键词: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"]}
}

  
 

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词