ubuntu vscode 学习

2023-05-16

扩展

visual studio keymap

快捷键

  • Open the Command Palette.
    • View > Command Palette… (Ctrl+Shift+P)
  • See an overview of the user interface.
    • Help: User Interface Overview in the Command Palette.
  • Install support for your favorite programming language from the Extensions view.
    • View > Extensions (Ctrl+Shift+X)
  • Change your keyboard shortcuts and easily migrate from other editors using keymap extensions.
    • File > Preferences > Migrate Keyboard Shortcuts from…
    • Code > Preferences > Migrate Keyboard Shortcuts from… on macOS
  • Open the Keyboard Shortcuts editor.
    • File > Preferences > Keyboard Shortcuts (Ctrl+K Ctrl+S)
    • Code > Preferences > Keyboard Shortcuts on macOS
  • Printable keyboard cheat sheet.
    • Help > Keyboard Shortcuts Reference (Ctrl+K Ctrl+R)
  • Customize your editor with color themes.
    • File > Preferences > Color Theme (Ctrl+K Ctrl+T)
    • Code > Preferences > Color Theme on macOS
  • Show all commands.
    • Help > Show All Commands (Ctrl+Shift+P)
  • Explore VS Code features in the Interactive Editor Playground.
    • Help > Editor Playground

文件组织

.vscode folder#

Workspace specific files are in a .vscode folder at the root. For example, tasks.json for the Task Runner and launch.json for the debugger.

Launch.json attributes

Variable substitution

Platform-specific properties

In the example below, debugging the program always stops on entry except on macOS:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/node_modules/gulp/bin/gulpfile.js",
      "stopOnEntry": true,
      "osx": {
        "stopOnEntry": false
      }
    }
  ]
}

编译调试顺序

  • launch.json用来调试

  • task.json用来生成,相当于是任务的集合,可通过ctrl+shift+p,运行任务,比如:

    {
    	"version": "2.0.0",
    	"tasks": [
    		{
    			"type": "cppbuild",
    			"label": "g++ build active file",
    			"command": "/usr/bin/g++",
    			"args": [
    				"-fdiagnostics-color=always",
    				"-g",
    				"${file}",
    				"-o",
    				"${fileDirname}/${fileBasenameNoExtension}"
    			],
    			"options": {
    				"cwd": "${fileDirname}"
    			},
    			"problemMatcher": [
    				"$gcc"
    			],
    			"group": "build",
    			"detail": "编译器: /usr/bin/g++"
    		}
    	]
    }
    

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

参考VS Code 运行C++程序以及TASKS.JSON和LAUNCH.JSON文件的基础配置

The task’s properties have the following semantic:

  • label: The task’s label used in the user interface.

  • type: The task’s type. For a custom task, this can either be shell or process. If shell is specified, the command is interpreted as a shell command (for example: bash, cmd, or PowerShell). If process is specified, the command is interpreted as a process to execute.

  • command: The actual command to execute.

  • windows: Any Windows specific properties. Will be used instead of the default properties when the command is executed on the Windows operating system.

  • group: Defines to which group the task belongs. In the example, it belongs to the test group. Tasks that belong to the test group can be executed by running Run Test Task from the Command Palette.

  • presentation: Defines how the task output is handled in the user interface. In this example, the Integrated Terminal showing the output is always revealed and a new terminal is created on every task run.

  • options: Override the defaults for cwd (current working directory), env (environment variables), or shell (default shell). Options can be set per task but also globally or per platform. Environment variables configured here can only be referenced from within your task script or process and will not be resolved if they are part of your args, command, or other task attributes.

  • runOptions: Defines when and how a task is run.

  • c_cpp_properties.json用来配置C++标准

可参考:

vscode-docs/launch-json-reference.md at main · microsoft/vscode-docs · GitHub

或网页Configure launch.json for C/C++ debugging in Visual Studio Code

以及Get Started with C++ on Linux in Visual Studio Code

VScode tasks.json和launch.json的设置

注意:

要保证launch.json中preLaunchTask的值与此文件中label的值相同

插件

  • visual studio keymap
  • makefile tool

Tips

调试

  • 如果应用程序在sudo环境下和普通用户环境下表现不一致并且当前调试需要管理员模式,在Ubuntu下一种可能的做法是:
  1. 设置配置文件(makefiletool自动生成,stopAtEntry需要自己加,敲“”后会出现提示):
{
    "makefile.extensionOutputFolder": "./.vscode",
    "makefile.launchConfigurations": [
        {
            "cwd": "/home/qemu/bin/debug",
            "binaryPath": "/home/qemu/bin/debug/hello",
            "binaryArgs": [],
            "stopAtEntry": true,
        }
    ]
}
  1. 运行或调试之后在终端(vscode的终端)输入sudo su,之后重新调试或运行
  • 通用makefile
    通用c/c++ makefile 参考

评论区找到的2,感谢!

参考

  • 官网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ubuntu vscode 学习 的相关文章

随机推荐

  • 图的存储结构-十字链表和邻接多重表

    1 十字链表 对于有向图来说 xff0c 邻接表是有缺陷的 关心了出度问题 xff0c 想了解入度就必须要遍历整个图才能知道 反之 xff0c 逆邻接表 解决了入度 却不了解出度的情况 有没有可能把邻接表和逆邻接表结合起来呢 xff1f 答
  • U3D开发的逆天级大型游戏有哪些

    1 World of Diving 潜水世界 一款潜水游戏 潜水世界 xff1a http dx60 downyouxi com qianshuishijie zip 氛围不错 xff0c 不过细看建模好像不是特别精细的样子 2 The F
  • 中断屏蔽技术

    1 中断屏蔽技术 xff1a 主要用于多重中断 多重中断 xff1a xff08 中断嵌套 xff09 当CPU 正在执行某个中断服务程序时 xff0c 另一个中断源又提出了新的中断请求 xff0c 而CPU 又响应了这个新的请求 xff0
  • 互斥锁Mutex和信号量

    Mutex是一把钥匙 xff0c 一个人拿了就可进入一个房间 xff0c 出来的时候把钥匙交给队列的第一个 一般的用法是用于串行化对critical section代码的访问 xff0c 保证这段代码不会被并行的运行 Is a key to
  • TCP/UDP的Socket编程接口详解

    socket概述 xff1a socket是在应用层和传输层之间的一个抽象层 xff0c 它把TCP IP层复杂的操作抽象为几个简单的接口供应用层调用已实现进程在网络中通信 socket起源于UNIX xff0c 在Unix一切皆文件哲学的
  • release版本程序调用libvlc接口出现异常

    release版本程序调用libvlc接口出现异常 super raymond lu at gmail dot com 转载请注明出处http blog csdn net raymond lu rl article details 7515
  • 对基于深度神经网络的Auto Encoder用于异常检测的一些思考

    一 前言 现实中 xff0c 大部分数据都是无标签的 xff0c 人和动物多数情况下都是通过无监督学习获取概念 xff0c 故而无监督学习拥有广阔的业务场景 举几个场景 xff1a 网络流量是正常流量还是攻击流量 视频中的人的行为是否正常
  • 阿里巴巴五轮面试经验分享

    拿到阿里实习offer xff0c 经历了5次面试 xff0c 其中4轮技术面 xff0c 1轮HR面试 在这里分享一下自己的面试经验和学习心得 希望能够帮助更多的小伙伴 我本科毕业于中南大学信管专业 xff0c 真正开始学习Java是在大
  • FishC笔记—20 讲 函数:内嵌函数和闭包

    本期内容详解 xff1a 1 内嵌函数 xff1a 函数内部新创建另一个函数 2 闭包 xff1a 函数式编程的重要语法 xff0c 如果在一个内部函数里 xff0c 对外部作用域 xff08 但不是在全局作用域的变量 xff09 进行引用
  • bash: setup.bash: No such file or directory和.bashrc文件的问题

    前段时间linux中打开终端时 xff0c 总是出现bash opt ros indig setup bash No such file or directory的问题 此问题跟每次终端打开时要加载的bash有关 xff0c 于是查bash
  • STL 容器、迭代器、算法归纳整理

    注 xff1a 文章由博主同步发布于 xff1a STL 容器 迭代器 算法小结 标准模板库 内容主要源自C 43 43 Standard Library 与 C 43 43 Primer STL是C 43 43 标准库的核心 xff0c
  • 对‘pthread_create’未定义的引用

    注 xff1a 本文由博主同步发布于 xff1a 对 pthread create 未定义的引用 问题 xff1a 使用CLion xff0c 在Linux下编写C 43 43 多线程程序 xff08 使用future和async xff0
  • 无人机4G数传一站多机模式

    随着4G的普及和5G技术的发展以及传统无人机数传距离的限制 xff0c 无人机联网的需求慢慢体现出来 xff0c 乐朴智能推出的无人机4G数传专为无人机应设计 xff0c 仅重49克方便无人机挂载 并且可以支持一站多机和多机互联的方式组网
  • 滑模原理框图

    这几天又重新复习了滑模控制原理 xff0c 借助相图来进行理解 xff0c 有了更深刻的认识 采用滑模控制要求系统是匹配条件下的 xff0c 更重要的是系统的扰动上界需要是已知的 xff0c 否则无法设置相应的切换增益用以抵抗干扰 xff0
  • 前端面试刷题网站汇总

    灵题库 http www lingtiku com 收集一线大厂面试真题 xff0c 还有专项训练 xff08 Promise 作用域 数据类型 React Vue 等等 xff09 以针对性提升 xff0c 每个题目有对应知识点的详细介绍
  • 大数据的感想

    1 大数据即全数据 xff08 即n 61 All xff0c 这里n为数据的大小 xff09 xff0c 其旨在收集和分析与某事物相关的 全部 数据 xff0c 而非仅分析 部分 数据 2 N 61 All xff08 所有 xff09
  • 完全搞懂shell脚本第一行:#!/bin/bash的含义

    shell脚本的第一行一般会写有以下字样 xff1a bin bash 或者 bin sh 或者 bin awk 比较常见的说法是 xff1a 第一行的内容指定了shell脚本解释器的路径 xff0c 而且这个指定路径只能放在文件的第一行
  • Python3 超好用的音频播放模块 playsound

    Python3 超好用的音频播放模块 playsound 前言playsound模块介绍一 模块安装二 使用三 使用中遇到大坑 xff1a 文件无法解除占用 xff01 前言 python2有个很好用的音频播放模块MP3player xff
  • ros中rviz查看激光雷达数据 hokuyo

    一开始没加tf会报错如下 WARN 1531227099 238940419 MessageFilter target 61 map Dropped 100 00 of messages so far 解决如下 启动传感器驱动 xff0c
  • ubuntu vscode 学习

    扩展 visual studio keymap 快捷键 Open the Command Palette View gt Command Palette Ctrl 43 Shift 43 P See an overview of the u