【C++】Visual Studio EditorConfig 格式设置
【C++】Visual Studio EditorConfig 格式设置
文章目录
- 【C++】Visual Studio EditorConfig 格式设置
- I - EditorConfig
- 1.1 - 通用设置
- indent_style
- indent_size
- tab_width
- end_of_line
- charset
- trim_trailing_whitespace
- insert_final_newline
- II - Visual Studio 特定键值
- 缩进设置
- cpp_indent_braces
- cpp_indent_multi_line_relative_to
- cpp_indent_within_parentheses
- cpp_indent_preserve_within_parentheses
- cpp_indent_case_contents
- cpp_indent_case_labels
- cpp_indent_case_contents_when_block
- cpp_indent_lambda_braces_when_parameter
- cpp_indent_goto_labels
- cpp_indent_preprocessor
- cpp_indent_access_specifiers
- cpp_indent_namespace_contents
- cpp_indent_preserve_comments
- 换行符设置
- cpp_new_line_before_open_brace_namespace
- cpp_new_line_before_open_brace_type
- cpp_new_line_before_open_brace_function
- cpp_new_line_before_open_brace_block
- cpp_new_line_before_open_brace_lambda
- cpp_new_line_scope_braces_on_separate_lines
- cpp_new_line_close_brace_same_line_empty_type
- cpp_new_line_close_brace_same_line_empty_function
- cpp_new_line_before_catch
- cpp_new_line_before_else
- cpp_new_line_before_while_in_do_while
- 间距设置
- cpp_space_before_function_open_parenthesis
- cpp_space_within_parameter_list_parentheses
- cpp_space_between_empty_parameter_list_parentheses
- cpp_space_after_keywords_in_control_flow_statements
- cpp_space_within_control_flow_statement_parentheses
- cpp_space_before_lambda_open_parenthesis
- cpp_space_within_cast_parentheses
- cpp_space_after_cast_close_parenthesis
- cpp_space_within_expression_parentheses
- cpp_space_before_block_open_brace
- cpp_space_between_empty_braces
- cpp_space_before_initializer_list_open_brace
- cpp_space_within_initializer_list_braces
- cpp_space_preserve_in_initializer_list
- cpp_space_before_open_square_bracket
- cpp_space_within_square_brackets
- cpp_space_before_empty_square_brackets
- cpp_space_between_empty_square_brackets
- cpp_space_group_square_brackets
- cpp_space_within_lambda_brackets
- cpp_space_between_empty_lambda_brackets
- cpp_space_before_comma
- cpp_space_after_comma
- cpp_space_remove_around_member_operators
- cpp_space_before_inheritance_colon
- cpp_space_before_constructor_colon
- cpp_space_remove_before_semicolon
- cpp_space_after_semicolon
- cpp_space_remove_around_unary_operator
- cpp_space_around_binary_operator
- cpp_space_around_assignment_operator
- cpp_space_pointer_reference_alignment
- cpp_space_around_ternary_operator
- 换行选项
- cpp_wrap_preserve_blocks
- 参考链接
I - EditorConfig
Visual Studio 自带支持 .editorconfig 文件,使用时,需要将 .editorconfig 文件放在工程的根目录。
关于 .editorconfig 文件,作用类似于 .clang-format,用于多人开发时多编辑器的配置,为了格式统一等等。
https://editorconfig.org
这个是 EditorConfig 的官方网站,网站中说明了哪些编辑器或者 IDE(集成开发环境) 内置支持此文件,哪些编辑器需要安装插件支持,以及对应编辑器插件的下载链接。
1.1 - 通用设置
禁用设置属性需要使用 unset
,举例:
indent_size = unset
表示移除 indent_size 的效果,取消 indent_size 的属性,使用编辑器的默认值
indent_style
缩进样式,可用的值为
- tab
- space
设置缩进使用制表符或空格
此属性值不区分大小写
indent_size
缩进大小,可设置的值为一个正整数或 tab,如果设置为 tab ,也就是与制表符长度相同,则 indent_size 会等于 tab_width,如果未指定 tab_width 则使用编辑器的制表符大小设置
此属性值不区分大小写
tab_width
单个制表符的大小,可以设置为一个正整数,默认值 在 indent_size 设置为数字时与此属性相同
end_of_line
行尾格式可以为三种
- lf
- crlf
- cr
lf 为 Line Feed 即 \n
cr 为 Carrier Return 即 \r
crlf 则为 \r\n
此属性值不区分大小写,如果需要跟随系统默认,则最好不设置此属性
charset
文件的编码字符集
可设置为
- latin1
- utf-8
- utf-16be
- utf-16le
- utf-8-bom
不区分大小写
BOM 为 byte-order mark 字节序标记
trim_trailing_whitespace
指定是否移除行尾空白符
- true 移除所有换行符之前的空白符
- false 保证编辑器保留空白符
不区分大小写
insert_final_newline
指定是否在文件末尾添加空白行,可设置为
- true
- false
II - Visual Studio 特定键值
Visual Studio 中C++ 格式设置 EditorConfig 属性以 cpp_ 为前缀。
示例
# 指定生效的文件
[*.{c++,cc,cpp,cxx,h,h++,hh,hpp,hxx,inl,ipp,tlh,tli}]cpp_indent_case_contents_when_block = true
cpp_new_line_before_open_brace_namespace = same_line
以下为 Visual Studio 和 VS Code 支持的所有 EditorConfig C++ 格式设置。
缩进设置
cpp_indent_braces
缩进大括号
可用值:true、false
cpp_indent_multi_line_relative_to
相对该对象缩进各行
可用值:
- outermost_parenthesis - 键入新行时,它会相对最外侧的左括号缩进。
- innermost_parenthesis - 键入新行时,它会相对最内侧的左括号缩进。
- statement_begin - 键入新行时,它会相对当前语句的开头缩进。
cpp_indent_within_parentheses
在圆括号内部输入新行时进行对齐
可用值:
- align_to_parenthesis - 将内容与左圆括号对齐。
- indent - 缩进新行。
cpp_indent_preserve_within_parentheses
可用值:true、false
在现有代码中,不要使用圆括号中的新行的对齐设置
cpp_indent_case_contents
缩进 case 内容
可用值:true、false
缩进 case 标签
cpp_indent_case_labels
缩进 case 标签
可用值:true、false
cpp_indent_case_contents_when_block
缩进 case 语句后面的大括号
可用值:true、false
cpp_indent_lambda_braces_when_parameter
缩进用作参数的 lambda 的大括号,可用值:true、false
cpp_indent_goto_labels
goto 标签的位置,可用值:
- one_left - 向左缩进一次
- leftmost_column - 移到最左侧的列
- none - 保留缩进
cpp_indent_preprocessor
预处理器指令位置,可用值:
- one_left - 向左缩进一次
- leftmost_column - 移到最左侧的列
- none - 保留缩进
cpp_indent_access_specifiers
缩进访问说明符 :true、false
cpp_indent_namespace_contents
缩进命名空间内容 :true、false
cpp_indent_preserve_comments
保留注释的缩进:true、false
换行符设置
cpp_new_line_before_open_brace_namespace
命名空间的左大括号的位置:
- new_line - 移动到新行
- same_line - 保持在同一行上,但在前面添加一个空格
- ignore - 不要自动重新定位
cpp_new_line_before_open_brace_type
类型的左大括号的位置:
- new_line - 移动到新行
- same_line - 保持在同一行上,但在前面添加一个空格
- ignore - 不要自动重新定位
cpp_new_line_before_open_brace_function
函数的左大括号的位置:
- new_line - 移动到新行
- same_line - 保持在同一行上,但在前面添加一个空格
- ignore - 不要自动重新定位
cpp_new_line_before_open_brace_block
控制块的左大括号的位置:
- new_line - 移动到新行
- same_line - 保持在同一行上,但在前面添加一个空格
- ignore - 不要自动重新定位
cpp_new_line_before_open_brace_lambda
lambda 的左大括号的位置:
- new_line - 移动到新行
- same_line - 保持在同一行上,但在前面添加一个空格
- ignore - 不要自动重新定位
cpp_new_line_scope_braces_on_separate_lines
将范围大括号放到单独的行上:true、false
cpp_new_line_close_brace_same_line_empty_type
对于空类型,将右大括号移动到左大括号所在的同一行:true、false
cpp_new_line_close_brace_same_line_empty_function
对于空的函数体,将右大括号移动到左大括号所在的同一行:true、false
cpp_new_line_before_catch
将 catch 和相似的关键字放在新行上:true、false
cpp_new_line_before_else
将 else 放在新行上:true、false
cpp_new_line_before_while_in_do_while
将 do-while 循环中的 while 放在新行上:true、false
间距设置
cpp_space_before_function_open_parenthesis
在函数名称与参数列表的左括号之间插入空格:
- insert - 插入空格
- remove - 移除空格
- ignore - 请勿更改空格
cpp_space_within_parameter_list_parentheses
在参数列表的圆括号中插入空格:true、false
cpp_space_between_empty_parameter_list_parentheses
当参数列表为空时在圆括号之间插入空格:true、false
cpp_space_after_keywords_in_control_flow_statements
在关键字与控制流语句中的左圆括号之间插入空格:true、false
cpp_space_within_control_flow_statement_parentheses
在控制语句的圆括号中插入空格:true、false
cpp_space_before_lambda_open_parenthesis
在 lambda 参数列表的左圆括号前面插入空格:true、false
cpp_space_within_cast_parentheses
在 C 样式强制转换的圆括号中插入空格:true、false
cpp_space_after_cast_close_parenthesis
在 C 样式强制转换的右圆括号后面插入空格:true、false
cpp_space_within_expression_parentheses
在带圆括号的表达式的圆括号中插入空格:true、false
cpp_space_before_block_open_brace
在块的左大括号前插入空格:true、false
cpp_space_between_empty_braces
在空大括号之间插入空格:true、false
cpp_space_before_initializer_list_open_brace
在统一初始化和初始值设定项列表的左大括号前插入空格:true、false
cpp_space_within_initializer_list_braces
在统一初始化和初始值设定项列表中插入空格:true、false
cpp_space_preserve_in_initializer_list
保留统一初始化和初始值设定项列表内的空格:true、false
cpp_space_before_open_square_bracket
在左方括号前插入空格:true、false
cpp_space_within_square_brackets
在方括号中插入空格:true、false
cpp_space_before_empty_square_brackets
在空方括号前插入空格:true、false
cpp_space_between_empty_square_brackets
在空方括号之间插入空格:true、false
cpp_space_group_square_brackets
将多维数组的方括号组合在一起:true、false
cpp_space_within_lambda_brackets
在 lambda 的方括号中插入空格:true、false
cpp_space_between_empty_lambda_brackets
lambda 空的方括号中的空格:true、false
cpp_space_before_comma
在逗号前插入空格:true、false
cpp_space_after_comma
在逗号后面插入空格:true、false
cpp_space_remove_around_member_operators
移除成员运算符前后的空格:true、false
cpp_space_before_inheritance_colon
在类型声明中的基类的冒号前插入空格:true、false
cpp_space_before_constructor_colon
在构造函数中的冒号前插入空格:true、false
cpp_space_remove_before_semicolon
移除分号前的空格:true、false
cpp_space_after_semicolon
在分号后面插入空格:true、false
cpp_space_remove_around_unary_operator
移除一元运算符和其操作数之间的空格 :true、false
cpp_space_around_binary_operator
二元运算符的间距:
- insert - 在二元运算符的前后插入空格。
- remove - 移除二元运算符周围的空格。
- ignore - 不要更改二元运算符周围的空格。
cpp_space_around_assignment_operator
赋值运算符的间距:
- insert - 在赋值运算符周围插入空格。
- remove - 移除赋值运算符周围的空格。
- ignore - 不要更改赋值运算符周围的空格。
cpp_space_pointer_reference_alignment
指针/引用对齐方式:
- left - 左对齐。
- center - 居中对齐。
- right - 右对齐。
- ignore - 保持不变。
cpp_space_around_ternary_operator
条件运算符的间距:
- insert - 在条件运算符周围插入空格。
- remove - 移除条件运算符周围的空格。
- ignore - 不要更改条件运算符周围的空格。
换行选项
cpp_wrap_preserve_blocks
块的换行选项:
- one_liners - 不要对单行代码块换行。
- all_one_line_scopes - 不要对左大括号和右大括号位于下一行上的代码块进行换行。
- never - 始终为块应用新行设置。
参考链接
-
EditorConfig
https://spec.editorconfig.org -
Microsoft
https://learn.microsoft.com/en-us/visualstudio/ide/cpp-editorconfig-properties?view=vs-2019 -
Github
https://github.com/editorconfig/editorconfig/wiki/EditorConfig-Properties
相关文章:

【C++】Visual Studio EditorConfig 格式设置
【C】Visual Studio EditorConfig 格式设置 文章目录 【C】Visual Studio EditorConfig 格式设置I - EditorConfig1.1 - 通用设置indent_styleindent_sizetab_widthend_of_linecharsettrim_trailing_whitespaceinsert_final_newline II - Visual Studio 特定键值缩进设置cpp_in…...

服务器单机大规模数据存储方案
大规模数据存储都需要解决三个核心问题: 1.数据存储容量的问题,既然大数据要解决的是数据 PB 计的数据计算问题,而一般的服务器磁盘容量通常 1~2TB,那么如何存储这么大规模的数据呢? 2.数据读写速度的问题&…...

ElasticSearch-集成ik分词器
本文已收录于专栏 《中间件合集》 目录 背景介绍版本选择优势说明集成过程1.下载安装包2.解压安装包3.重启ElasticSearch服务3.1通过ps -ef | grep elastic查看正在启动的es进程号3.2使用kill -9 xxx 杀死进程3.3使用 ./elasticsearch 启动es服务 分词测试细粒度分词方式分词请…...

c++版opencv求二值图的质心
代码 #include <iostream> #include <opencv2/core.hpp> #include <opencv2/highgui.hpp> #include <opencv2/imgproc.hpp>int main(int argc, char* argv[]) {cv::Mat input_image cv::imread("Untitled.png", cv::IMREAD_GRAYSCALE);cv:…...

6、深入解析Kotlin类与对象:构造、伴生、单例全面剖析
前言 本篇文章将带您了解Kotlin编程中的重要概念:类及构造函数、访问修饰符、伴生对象和单例模式。就像搭积木一样,我们会逐步揭开这些概念的面纱,让您轻松理解它们的作用和用法。无论您是编程新手还是有经验的开发者,本文都将为…...

【开源ESP32谷歌恐龙小游戏】【游戏演示和介绍】LVGL ST7789 适用于Arduino
【源码及教程地址-持续更新】 ESP32 C3 LVGL 迷你小电视 Google谷歌恐龙小游戏 1.9寸LCD显示屏开发板 ST7789 适用于Arduino开发板,教程,资料,程序,代码,PDF手册 【开源 & ESP32谷歌恐龙小游戏】【游戏演示和介绍】LVGL ST7789 适用于Arduin...

openCV实战-系列教程7:轮廓检测2与模板匹配(轮廓检测/轮廓特征/轮廓近似/轮廓边界矩阵/轮廓边界圆/模版匹配)、原理解析、源码解读
🧡💛💚💙💜OpenCV实战系列总目录 打印一个图片可以做出一个函数: def cv_show(img,name):cv2.imshow(name,img)cv2.waitKey()cv2.destroyAllWindows() 1、轮廓特征与近似 1.1 轮廓特征 前面我们计算了…...

cs231n_1_IntroToConv
参考的视频来自如下链接https://www.bilibili.com/video/BV1Ed4y1b7bm/ 参考笔记如下https://blog.csdn.net/TeFuirnever/article/details/89059673 x.1 CV历史 生物快速发展于5.4亿年前,那时的化石显示生物进化出了视觉,视觉使得生物多样性大爆炸。 …...

OPENCV实现SURF特征检测
1、SURF优点:SIFT速度慢,一次出现了SURF;2、使用SURF步骤:surf = cv2.xfeatures2d.SURF_create()kp,des = surf.detectAndComputer(img,mask)# -*- coding:utf-8 -*- """ 作者:794919561 日期:2023/8/31 """# -*-...

Android Gradle 同步优化
作者:究极逮虾户 很多人听到方法论三个字,就觉得我要开始pua,说我阿里味,但是我觉得这个查问题的方式可能会对大家有点帮助。 很多人都会有这样的困扰,给你的一个工作内容是一个你完全陌生的东西,第一选择…...

BeautifulSoup:学习使用BeautifulSoup库进行HTML解析和数据提取。
BeautifulSoup是一个用于解析HTML和XML文档的Python库。它可以帮助我们从网页中提取数据,并以易于操作的方式进行分析。 以下是使用BeautifulSoup进行HTML解析和数据提取的基本语法: 安装BeautifulSoup库:首先,你需要在你的Python…...

基于沙猫群算法优化的BP神经网络(预测应用) - 附代码
基于沙猫群算法优化的BP神经网络(预测应用) - 附代码 文章目录 基于沙猫群算法优化的BP神经网络(预测应用) - 附代码1.数据介绍2.沙猫群优化BP神经网络2.1 BP神经网络参数设置2.2 沙猫群算法应用 4.测试结果:5.Matlab代…...

PCL 判断三点共线(三维空间)
文章目录 一、简介二、实现代码三、实现效果参考资料一、简介 继续之前的思路PCL 判断两条线段的平行性(三维空间),我们可以把判断三点共线看做是判断两条线段是否具有平行性,且这两条线段共用其中一个端点,基于此当这两条线段平行时,则证明这三点共线。 二、实现代码 /…...

【数据库】事务(概念和特点)
一、 什么是事务: 事务是在数据库中执行的一系列操作单元,这些操作要么全部成功提交,要么全部失败回滚。 二、事务的特点: 原子性(Atomicity):事务是一个不可分割的操作单元,要么…...

LA@齐次线性方程组解的结构
文章目录 齐次线性方程组解的结构🎈解的性质齐次线性方程组的解的线性组合还是方程组的解基础解系通解 定理:齐次线性方程组基础解系存在定理齐次线性方程组的基础解系包含的向量个数(秩)👺应用和示例推论1推论2推论3:转置矩阵对的乘积秩的性质非自由未知…...

Docker修改容器ulimit的全部方案及各方案的详细步骤
要修改Docker容器的ulimit(用户资源限制),有以下三种方案,每个方案的详细步骤如下: 方案一:在Dockerfile中设置ulimit 打开您的Dockerfile。在文件中添加以下命令来修改ulimit:RUN ulimit -n …...
进程间通信-Binder
Binder Binder框架概述服务端Binder驱动客户端 设计服务端和客户端设计服务端客户端设计 Binder与ServiceServiceAIDL 保证包裹内参数顺序IMusicPlayerServiceProxyStub 系统服务中的Binder对象ServiceManger管理的服务理解Manger功能快捷键合理的创建标题,有助于目…...

一个简单的vim例子
一.欢迎来到我的酒馆 在本章节介绍vim工具。 目录 一.欢迎来到我的酒馆二.什么是vim三.开始使用vim 二.什么是vim 2.1什么是vim vim是一种Linux命令行类型的文本编辑器。vim指的是"vi improved",意思是vi工具的升级版。vim是基于vi实现的&#x…...

sql server 备份到网络共享
场景:sql server服务器A将数据库备份文件备份到服务器B 1)服务器B创建共享目录 这里我将 D:\ProDbBak 共享,并且Everyone完全控制 2)sql server服务器A能够访问服务器B共享目录,并且能完全控制 3)修改服务…...

程序与进程
一、程序是怎么被执行的 1.在程序中,由引导代码去调用程序中得main函数,而这个过程由链接器完成,链接器将引导代码链接到我们的应用程序构成可执行文件。 2.程序运行需要通过操作系统的加载器来实现,加载器是操作系统中的程序&a…...

大模型从入门到应用——LangChain:链(Chains)-[链与索引:图问答(Graph QA)和带来源的问答(QA with Sources)]
分类目录:《大模型从入门到应用》总目录 图问答(Graph QA) 创建图 在本节中,我们构建一个示例图。目前,这对于较小的文本片段效果最好,下面的示例中我们只使用一个小片段,因为提取知识三元组对…...

spark sql 数据倾斜--join 同时开窗去重的问题优化
spark sql 数据倾斜–join 同时开窗去重的问题优化 文章目录 spark sql 数据倾斜--join 同时开窗去重的问题优化结论1. 原方案:join步骤时,同时开窗去重数据倾斜 2. 优化2.1 参数调优2.2 SQL优化 背景: 需求:在一张查询日志表中&a…...

lv3 嵌入式开发-linux介绍及环境配置
目录 1 UNIX、Linux和GNU简介 2 环境介绍 3 VMwareTools配置 4 vim配置: 1 UNIX、Linux和GNU简介 什么是UNIX? unix是一个强大的多用户、多任务操作系统,支持多种处理器架构 中文名 尤尼斯 外文名 UNIX 本质 操作系统 类型 分时操作系统 开…...

RabbitMQ工作模式-路由模式
官方文档参考:https://www.rabbitmq.com/tutorials/tutorial-four-python.html 使用direct类型的Exchange,发N条消息并使用不同的routingKey,消费者定义队列并将队列routingKey、Exchange绑定。此时使用direct模式Exchange必须要routingKey完成匹配的情况下消息才…...

StringIO BytesIO
上一篇中我们介绍了文件的基本读写操作,但是很多时候数据的读写并不一定都是在文件中,我们也可以在内存中读写数据,因此引出我们今天的主要内容,即 StringIO 和 BytesIO,让你学会在内存中进行数据的基本读写操作。 1 …...

通讯录管理系统(个人学习笔记黑马学习)
1、系统需求 通讯录是一个可以记录亲人、好友信息的工具。 本教程主要利用C来实现一个通讯录管理系统系统中需要实现的功能如下: 添加联系人:向通讯录中添加新人,信息包括(姓名、性别、年龄、联系电话、家庭住址)最多记录1000人显示联系人:显示通讯录中所有联系人信…...

[SpringBoot3]远程访问@HttpExchange
六、远程访问HttpExchange[SpringBoot3] 远程访问是开发的常用技术,一个应用能够访问其他应用的功能。SpringBoot提供了多种远程访问的技术。基于HTTP协议的远程访问是最广泛的。SpringBoot中定义接口提供HTTP服务。生成的代理对象实现此接口,代理对象实…...

Linux安装ntp并使用阿里云配置ntp服务器
安装 NTP 客户端: 打开终端,以 root 权限执行以下命令来安装 NTP 客户端: sudo zypper install ntp 编辑 NTP 配置文件: 使用文本编辑器打开 NTP 的配置文件 /etc/ntp.conf,例如使用 nano 编辑器: sudo v…...

js常用方法总结
1、slice 和 splice slice表示截取,slice(start,end),不改变原数组,返回新数组。 splice表示删除,splice(start,length,item),会改变原数组,从某个位置开始删除多个元素,并可以插入新的元素。…...

在PHP中安装Composer并管理Vue前端依赖包
系列文章目录 文章目录 系列文章目录前言一、安装Composer二、使用Composer管理PHP依赖包三、使用npm管理Vue前端依赖包总结 前言 在开发Web应用程序时,使用Composer来管理PHP的依赖包和Vue前端的依赖包是一种很常见的做法。Composer是PHP的包管理工具,…...