问题描述
限时送ChatGPT账号..我想要实现的是找到是否存在一种方法来格式化 C++ 中的运算符之间的空间,Visual Studio(在我的情况下为 2012).
例如在 C# 中编写以下代码行:
int number=10;
然后在 C# 中按 Ctrl+K,Ctrl+D 将代码格式化为:>
int number = 10;
可以看出,在等号运算符 (=
) 之间添加了空格.当我尝试在同一个 Visual Studio 中格式化代码时,但对于 C++,仅在分支上添加缩进,但运算符之间的空格保持不变.
是否可以为 C++ 实现相同的功能?
编辑
这是我在 C/C++ 中看到的 > 格式:
解决方案我不再有 VS 2012,但对于 VS 2013 和 2015,您可以执行以下操作(我想它并没有发生很大变化):>
检查工具>选项...>文本编辑器>C/C++>格式>间距,并找到运算符的间距"
在那里你应该有一些设置,比如在二元运算符前后插入空格"
在您的特定情况下,您需要确保选中在赋值运算符周围插入空格".
之后,自动格式化应该会为您处理.
我能够检查一台装有 VS 2012 的机器,实际上没有这样的选项(msdn 链接).如果你想要这个能力,听起来你需要升级.
What I am trying to acheive is to find if there exists a way to format the space between the operators in C++, Visual Studio (2012 in my case).
For example writing the following line of code in C#:
int number=10;
Then hitting Ctrl+K,Ctrl+D in C# is formatting the code to:
int number = 10;
As it can be seen there were added spaces between the equal operator (=
). When I try to format the code in the same Visual Studio, but for C++, is added indentation only on branches, but the space between operators remains the same.
Is it possible to achieve the same functionality for C++?
Edit
This is what I see in C/C++ > Formatting:
解决方案I no longer have VS 2012, but for VS 2013 and 2015 you can do the following (I imagine it hasn't changed a whole lot):
Check Tools > Options... > Text Editor > C/C++ > Formatting > Spacing, and find "Spacing for operators"
There you should have a number of settings, like "insert spaces before and after binary operators"
In your specific case, you'll want to make sure "Insert spaces around assignment operators" is selected.
Afterwards, auto-format should take care of it for you.
Edit: I was able to check a machine that had VS 2012, and indeed there is no option like this (msdn link). Sounds like you need to upgrade if you want this ability.
这篇关于如何格式化运算符 C++ Visual Studio 之间的空间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
更多推荐
[db:关键词]
发布评论