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

vscode配置

1. 编辑界面右侧显示80字符分割线

界面左上角选择"文件->首选项->设置",进入设置界面,选择"文本编辑器->Rulers->在setting.json中编辑",或者直接所搜rulers
在这里插入图片描述
在这里插入图片描述

2. 添加注释头

在这里插入图片描述

{
    "add brief":
    {
        "prefix": ".brief",
        "body": [
        "",
        "/**",
        " * @brief : $1",
        " */",
        "$2",
        ],
    },

    "add enum template":
    {
        "prefix": ".enumTemplate",
        "body": [
        "",
        "/**",
        " * @brief : 错误代码定义",
        " */",
        "typedef enum",
        "{",
        "	ERR_SUCCESS       = 0,           //< 成功",
        "	ERR_FAILED        = -1,          //< 失败",
        "	ERR_INVALID_PARAMETER = -1000,   //< 无效参数",
        "	ERR_NOT_INITED,                  //< 未初始化",
        "	ERR_INITED,                      //< 已初始化$1",
        "} ErrCode;",
        ""
        ],
    },

    "Add File Header": {
        "prefix": ".fileHader",
        "body": [
            "/**"
            "  * @file    : ${TM_FILENAME}",
            "  * @brief   : $1",
            "  * @version : V1.0.0",
            "  * @date    : ${CURRENT_YEAR}-${CURRENT_MONTH}-${CURRENT_DATE}",
            "  */",
            "#ifndef __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
            "#define __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__",
            "",
            "/*================================= Includes =================================*/",
            "$2",
            "",
            "/*================================= Defines ==================================*/",
            "$3",
            "",
            "/*============================= Static Functions =============================*/",
            "$4",
            "",
            "/*============================= Public Functions =============================*/",
            "$5",
            "",
            "#endif /* __${TM_FILENAME_BASE/(.*)/${1:/upcase}/}_H__ */",
        ],
        "description": "Add file describe"
    },

    "add func header":{
        "prefix": ".funcHeader",
        "body": [
            "",
            "/**",
            " * @brief : $1",
            " * @param [$2]	$3  : $4",
            " * @param [$5]	$6  : $7",
            " * @return 返回错误码ErrCode",
            " */",
        ]
    },

    "check conditon": {
        "prefix": ".checkConditon",
        "body": [
            "#define CHECK_CONDITION(condition, error_code, error_message)     \\",
            "        do {                                                      \\",
            "            if (!(condition)) {                                   \\",
            "                $1fprintf(stderr, \"Error: %s\\n\", error_message);    \\",
            "                return error_code;                                \\",
            "            }                                                     \\",
            "        } while (0) $2",
            "$3",
        ]
    },

    "check param": {
        "prefix": ".checkParam",
        "body": [
            "#define CHECK_PARAM(param, error_code)                            \\",
            "        do {                                                      \\",
            "            if (!(param)) {                                       \\",
            "                $1fprintf(stderr, \"Error: invalid param\\n\");        \\",
            "                return error_code;                                \\",
            "            }                                                     \\",
            "        } while (0) $2",
            "$3",
        ]
    },

    "select timeout": {
        "prefix": ".select",
        "body": [
            "#include <sys/select.h>",
            "#include <sys/time.h>",
            "#include <unistd.h>",
            "$1",
            "/**",
            "  * @brief : select_with_timeout",
            "  * @param [in]	fd          : 文件描述符",
            "  * @param [in]	timeout_ms  : 超时时间(ms)",
            "  * @return true  : 文件描述符准备好",
            "  * @return false : 超时或出错",
            "  */",
            "bool select_with_timeout(int fd, int timeout_ms) {",
            "    fd_set read_set;",
            "    FD_ZERO(&read_set);",
            "    FD_SET(fd, &read_set);",
            "",
            "    // 设置超时时间",
            "    struct timeval tv;",
            "    tv.tv_sec = timeout_ms / 1000;",
            "    tv.tv_usec = (timeout_ms % 1000) * 1000;",
            "",
            "    // 调用 select 函数",
            "    int ready = ::select(fd + 1, &read_set, nullptr, nullptr, &tv);",
            "",
            "    if (ready == -1) { ",
            "        $1fprintf(stderr, \"Error: %s\\n\", strerror(errno));",
            "        return false;",
            "    }",
            "",
            "    // 检查文件描述符是否准备好",
            "    return ready > 0 && FD_ISSET(fd, &read_set);",
            "}",
            "",
        ]
    },

    "delete class functions": {
        "prefix": ".deleteClassFunctions",
        "body": [
            "$1(const $1 &) = delete;",
            "$1($1 &&)      = delete;",
            "$1 &operator=(const $1 &) = delete;",
            "$1 &operator=($1 &&)      = delete;",
            "",
        ]
    },

    "class define": {
        "prefix": ".class",
        "body": [
            "class $1" 
            "{",
            "public:",
            "    $1()  = default;",
            "    ${2:virtual }~$1() = default;",
            "",
            "    $1(const $1 &) = delete;",
            "    $1($1 &&)      = delete;",
            "    $1 &operator=(const $1 &) = delete;",
            "    $1 &operator=($1 &&)      = delete;",
            "",
            "protected:",
            "",
            "private:",
            "    $3",
            "};",
            "$4"
        ]
    },
}

http://www.kler.cn/a/414706.html

相关文章:

  • QChart数据可视化
  • ubuntu22开机自动登陆和开机自动运行google浏览器自动打开网页
  • 银联Java后端开发面试题及参考答案
  • 鸿蒙面试---都用过哪些装饰器
  • 网络安全问题与大忌
  • 11.19c++面向对象+单例模式
  • 淘宝商品信息获取:Python爬虫技术的实际应用
  • Spring Boot的理解
  • 适用于学校、医院等低压用电场所的智能安全配电装置
  • MacOS SourceTree Git的使用
  • Wordcloud也能生成一个,带html的词云图文件吗??
  • python: generator model using mysql9.0 or postgreSQL 17.0
  • 基于SpringBoot的“财务管理系统”的设计与实现(源码+数据库+文档+PPT)
  • Java基础面试题07:finalize() 方法什么时候被调用?析构函数(finalization)的目的是什么?
  • 【unity】WebSocket 与 EventSource 的区别
  • 状态模式S
  • 0.查找命令
  • 【docker 拉取镜像超时问题】
  • NeurIPS 2024 数据集汇总|覆盖云层去除/化学光谱/歌声音频/自动驾驶/昆虫标本······...
  • AI 声音:数字音频、语音识别、TTS 简介与使用示例
  • 爬虫开发(5)如何写一个CSDN热门榜爬虫小程序
  • 学习日志 --A5rZ
  • git:下载与安装
  • HTTPS的安全性优势
  • Pytorch中反向传播
  • C++初阶(十六)--STL--list的模拟实现