码农知识堂 - 1000bd
  •   Python
  •   PHP
  •   JS/TS
  •   JAVA
  •   C/C++
  •   C#
  •   GO
  •   Kotlin
  •   Swift
  • VSCode 和 CLion


    在这里插入图片描述


    文章目录

    • 一、VSCode
      • 1、文档
      • 2、插件
      • 3、智能编写
      • 4、VSCode 与 C++
        • (1)安装
        • (2)调试
          • (a)使用 CMake 进行跨平台编译与调试
          • (b)launch.json
          • (c)传参
        • (3)clang-format
      • 5、VSCode 与 Qt
        • (1)使用
        • (2)问题
      • 6、code-server
    • 二、CLion


    一、VSCode

    1、文档

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

    2、插件

    使用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 中文乱码设置

    3、智能编写

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

    4、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
                    }
                ]
            }
        ]
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 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"
            }
        ]
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    (c)传参

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

    (3)clang-format

        各个 IntelliSense 都有自己的代码格式化,可以不使用 clang-format 进行格式化,此处列出备用。

    1. 下载插件
      在这里插入图片描述
    2. 下载 clang-format
      linux
    sudo apt-get install clang-format
    
    • 1
    1. 设置
      (1)首选项设置
          打开首选项设置(ctrl + ,),搜索format .
         
      (2)可勾选format on save 自动保存。
          Settings > Text Editor > Formatting > Format On Save
      在这里插入图片描述
      (3)C_Cpp: Clang_format_style 决定格式化形式,若为file,则调用在workspace中的.clang-format
          Settings > Extensions > C/C++ > C_Cpp: Clang_format_style
      在这里插入图片描述
      (4)C_Cpp: Clang_format_fallback Style ,若上图变量为file,但无.clang-format文件则按照此处规则。
          Settings > Extensions > C/C++ > C_Cpp: Clang_format_fallback
      在这里插入图片描述
      (5)生成 .clang-format
          powershell 中输入:
    clang-format -style=llvm -dump-config > .clang-format
    
    • 1

    VS Code C++ 代码格式化方法(clang-format)
    VSCode更改格式化C++代码方式
    Ubuntu下VSCode配置Clang-format,并在保存时自动格式化代码的方法(带配置文件)

    5、VSCode 与 Qt

    (1)使用

    1. 使用 Qtcreator 创建 cmake 工程
      在这里插入图片描述
      用vscode开发qt linux系统使用vscode进行qt开发
      如何使用VSCode开发Qt项目?_神奇小邓的博客-CSDN博客_vscode开发qt

    2. 生成的文件大致如下
      在这里插入图片描述

    3. 启动VSCode
      打开终端(cmd或bash),进入当前代码所在的文件夹,输入

    # 设置Qt运行库的环境变量
    set PATH=%PATH%;D:/Qt6/6.2.2/msvc2019_64/bin
     
    # 运行VSCode
    code .
    
    • 1
    • 2
    • 3
    • 4
    • 5
    1. 生成与调试
      参考前面的cmake生成与调试

    (2)问题

    • 找不到Qt
      修改 CMakeLists.txt,添加搜索路径:
    # 添加 begin
    set(CMAKE_PREFIX_PATH "D:/Qt6/6.2.2/msvc2019_64")
     
    message("CMAKE_PREFIX_PATH=${CMAKE_PREFIX_PATH}")
     
    # 添加 end
     
    find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
    find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 运行找不到 Qt 库
      在环境变量中添加Qt运行库路径
      或者 在终端中设置QT运行库路径到环境变量中,然后启动 VSCode

    6、code-server

    服务器部署code-server
    github code-server

    linux 下启动 code-server

    #!/bin/bash
    #pid=`pgrep code-server`
    pid=`ps aux | grep /usr/lib/code-server | grep -v grep`
    if test "$pid" ;then
            echo $pid
            echo code-server already running...
    else
            echo $pid
            echo Will run code-server
            code-server &
    fi
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    二、CLion

    官方文档 Learn CLion
    Quick start guide | CLion
    其他版本 - CLion

    clion无限重置试用插件_哪都通临时员工的博客-CSDN博客_clion 无限试用
    clion/ide 正版过期重置时间(适合2021.2.2及以下,3的不行)

    Clion 打开Qt的ui文件_L-Super的博客-CSDN博客_clion ui

    如果 designer 打不开 ui 文件,可以把
    实参(Arguments)改为 F i l e P a t h FilePath FilePath

    解决 CLion 远程调试时,debug信息乱码的问题_非攻墨门的博客-CSDN博客

    IntelliJ IDEA 快捷键大全 + 动图演示,这效果太炸了

       

  • 相关阅读:
    Android自定义圆弧进度条(半圆进度条) 圆弧渐变色进度条带指示 圆弧宽高可自由修改
    CodeQL数据库构建原理分析
    flash内存分配和使用注意事项
    OpenMLDB 基于 Kubernetes 的部署全攻略
    【SpringBoot】| SpringBoot 集成 Redis
    神经网络算法的具体流程,神经网络算法难不难
    SSM注解大全
    Python: Decorator Pattern
    MySQL 8.0.35 企业版比社区版性能高出 25%?
    Elasticsearch 出现 “429 rejected” 报错,怎么办?
  • 原文地址:https://blog.csdn.net/Liuqz2009/article/details/133266775
  • 最新文章
  • 攻防演习之三天拿下官网站群
    数据安全治理学习——前期安全规划和安全管理体系建设
    企业安全 | 企业内一次钓鱼演练准备过程
    内网渗透测试 | Kerberos协议及其部分攻击手法
    0day的产生 | 不懂代码的"代码审计"
    安装scrcpy-client模块av模块异常,环境问题解决方案
    leetcode hot100【LeetCode 279. 完全平方数】java实现
    OpenWrt下安装Mosquitto
    AnatoMask论文汇总
    【AI日记】24.11.01 LangChain、openai api和github copilot
  • 热门文章
  • 十款代码表白小特效 一个比一个浪漫 赶紧收藏起来吧!!!
    奉劝各位学弟学妹们,该打造你的技术影响力了!
    五年了,我在 CSDN 的两个一百万。
    Java俄罗斯方块,老程序员花了一个周末,连接中学年代!
    面试官都震惊,你这网络基础可以啊!
    你真的会用百度吗?我不信 — 那些不为人知的搜索引擎语法
    心情不好的时候,用 Python 画棵樱花树送给自己吧
    通宵一晚做出来的一款类似CS的第一人称射击游戏Demo!原来做游戏也不是很难,连憨憨学妹都学会了!
    13 万字 C 语言从入门到精通保姆级教程2021 年版
    10行代码集2000张美女图,Python爬虫120例,再上征途
Copyright © 2022 侵权请联系2656653265@qq.com    京ICP备2022015340号-1
正则表达式工具 cron表达式工具 密码生成工具

京公网安备 11010502049817号