使用Artistic Style代码格式化程序,我如何实现相反的目标--break-after-logical / -xL,如果我有......
if (thisVariable1 == thatVariable1
|| thisVariable2 == thatVariable2
|| thisVariable3 == thatVariable3)
...
Run Code Online (Sandbox Code Playgroud)
......我明白了......
if (thisVariable1 == thatVariable1 || thisVariable2 == thatVariable2 || thisVariable3 == thatVariable3)
...
Run Code Online (Sandbox Code Playgroud) 将函数的左大括号移到下一行是一种常见做法。如何使用 astyle(代码美化器)在类方法中应用它?
例子:
// this is an initial C++ code
class Class
{
public:
static int foo(bool x) {
if (x) {
return 42;
} else {
return 0;
}
}
};
Run Code Online (Sandbox Code Playgroud)
修改后的版本应该是:
class Class
{
public:
static int foo(bool x)
{ // this brace in next line
if (x) {
return 42;
} else {
return 0;
}
}
};
Run Code Online (Sandbox Code Playgroud)
我所有的尝试都只适用于全局函数。
在 Eclipse 中,我总是使用Ctrl + shift + fIDE 中的自动格式化代码。
Dev-C++中是否有类似的功能,或者是否有一些可用于格式化我的 C/C++ 代码的插件?
我最近遇到了 astyle 的使用问题,我一直无法弄清楚。我不确定这是否是一个错误,或者我只是错误地使用了 astyle 工具。我尝试使用“--exclude”选项来忽略处理中的文件和目录,但继续收到“不匹配的”排除错误并且 astyle 终止:
bwallace$ ls -l foo.c
-rw-r--r-- 1 bwallace 1767304860 22 Aug 1 21:36 foo.c
bwallace$ astyle ./foo.c --exclude=./foo.c -v
Artistic Style 2.04 08/03/2014
Exclude (unmatched) ./foo.c
Artistic Style has terminated
Run Code Online (Sandbox Code Playgroud)
当我传递“-i”(忽略排除错误)时,astyle 按预期处理文件。因此,“排除”语句似乎有问题。
bwallace$ astyle ./foo.c --exclude=./foo.c -v -i
Artistic Style 2.04 08/03/2014
Exclude (unmatched) ./foo.c
Unchanged ./foo.c
0 formatted 1 unchanged 0.00 seconds 2 lines
Run Code Online (Sandbox Code Playgroud)
这是一个错误吗?我是否错误地使用了 astyle?任何帮助,将不胜感激。
如何使用 删除代码中的多余空格astyle?例如我想转换以下代码:
void foo ( int a , int c )
{
d = a+ c;
}
Run Code Online (Sandbox Code Playgroud)
对此:
void foo (int a, int c)
{
d = a + c;
}
Run Code Online (Sandbox Code Playgroud)
但是 astyle 目前正在将其转换为:
void foo (int a , int c)
{
d = a + c;
}
Run Code Online (Sandbox Code Playgroud) astyle是否具有会执行以下操作的选项:
"For the given list of files, list the files that *would be* modified by astyle."
Run Code Online (Sandbox Code Playgroud)
因此,基本上列出不符合astyle的文件,但实际上不要更改它们。我浏览了手册页,找不到任何有用的信息。astyle创建.orig文件,我可以使用该信息,但是我宁愿不要使驱动器混乱,即使astyle可以在事后进行清除。我真的很想这样的选择。
我刚开始使用astyle。
谢谢!