本文最后更新于:2024年1月14日 晚上

C++ 虽然缩进不敏感,但是为了在协作项目中统一代码风格,可以使用格式设置插件 AStyleExtension 。

简介

安装配置

  • 下载文件后双击走流程即可完成安装
  • 安装完成后需要做一点格式配置,选择: 工具 -> 选项 -> AStyleFormatter -> General
  • 点击 Edit,输入如下内容:
1
--style=1tbs --indent=spaces=4 --align-pointer=type --align-reference=type --indent-cases --indent-col1-comments --pad-oper --pad-header --pad-comma --unpad-paren --close-templates --convert-tabs --mode=c
  • 保存后选项页效果:

使用插件

  • 保存代码就会被自动统一格式

  • 示例:

    混乱的代码:

    1
    2
    3
    4
    5
    int main(){printf("Hello Open CV!");
    string image_path = "cmk.png";
    PatternSearch main_obj;
    main_obj.infer(image_path);
    return 0;}

    保存后:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    int main()
    {
    printf("Hello Open CV!");
    string image_path = "cmk.png";
    PatternSearch main_obj;
    main_obj.infer(image_path);
    return 0;
    }

参考资料



文章链接:
https://www.zywvvd.com/notes/coding/cpp/extension/astyleextension/


“觉得不错的话,给点打赏吧 ୧(๑•̀⌄•́๑)૭”

微信二维码

微信支付

支付宝二维码

支付宝支付

Visual Studio 统一代码格式插件 AStyleExtension
https://www.zywvvd.com/notes/coding/cpp/extension/astyleextension/
作者
Yiwei Zhang
发布于
2023年1月19日
许可协议