IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> ubuntu vscode 学习 -> 正文阅读

[开发工具]ubuntu vscode 学习

扩展

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的值相同

插件

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,之后重新调试或运行

评论区找到的2,感谢!

参考

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-04-29 12:19:59  更:2022-04-29 12:20:46 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年11日历 -2024/11/26 2:31:40-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码