我如何在linux中使用“缩进”实用程序纠正命名空间块中的缩进
How can I correct indentation in namespace block using `indent` utility in linux
(我已经在https://codereview.stackexchange.com/上发布了这个问题,并标记为离题。主持人建议在SO发布问题
我使用indent
来纠正缩进。一切正常,除了名称空间块缩进。
我有示例代码:
$ cat test2.cc
#include <iostream>
namespace API
{
void f ()
{
std::cout << "f() called" << std::endl;
}
}
但运行indent
后,我得到:
$ indent -st -bl -bli0 -i 4 -c 4 -kr -nce -bls test2.cc
#include <iostream>
namespace API
{
void f()
^^^^<=== I don't want these indentation
{
std::cout << "f() called" << std::endl;
}
}
我不希望第一次缩进命名空间块,很难找到任何相关的缩进选项(这是非常复杂的)。我怎样才能算出来呢?
indent
是用来格式化C代码的。它并不真正了解c++语法,例如namespace
。
我建议使用clang-format
,这是一个c++格式化程序。
相关文章:
- clang格式:宏的缩进
- C++setiosflags函数操纵器-未确定的缩进
- VSCode 中带有 C/C++ 扩展名的多行注释缩进错误
- C++实用程序::转换在静态链接库中不起作用
- 通过实用程序 fn 将捕获的 lambda 传递给 C 样式回调 - 错误
- 当我尝试进行TPC-E测试时,实用程序抱怨"undefined reference"
- 在没有格式说明符的情况下在c++中使用类似printf的实用程序
- C++实用程序,用于将长开关语句转换为封装开关案例阶梯的简洁函数调用
- 如何使用c++调整文本文件中代码的缩进?
- 如何在C++中制作 clang 格式的缩进 extern C 块?
- 在 vscode 中使用特定缩进/对齐 C/C++ 自动格式化
- 创建文件函数是否可以打开仅在WinObj实用程序中的全局目录下列出的设备的句柄?
- "If Else"语句缩进在C++中是否重要?
- CLion 行注释的不一致自动缩进
- C :实用程序名称空间中的正态分布
- 实用程序函数不会在 .h 文件中初始化并在 main 中定义.cpp
- 用于创建integral_constants的 aribtrary 元组的通用实用程序
- Qt 创建器中的实用程序::转换::to_string_t中的链接错误
- 我如何在linux中使用“缩进”实用程序纠正命名空间块中的缩进
- 十六进制转储实用程序c++显示十六进制和Ascii