0

(I've posted this question at https://codereview.stackexchange.com/ and marked off-topic. Moderator suggested to post question at SO)

I'm using indent to correct indentation. Everything is fine except indent in namespace block.

I have sample codes:

$ cat test2.cc
#include <iostream>

namespace API
{
void f ()
{
    std::cout << "f() called" << std::endl;
}
}

But after running indent I got:

$ 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;
    }
}

I don't want first indentation of namespace block and hard to find any related indent option (it's very complicated). How can I work it out? Any suggestion would be appreciated.

1 Answer 1

2

indent is designed to format C code. It's not really aware of C++ syntax, such as namespace.

I'd suggest using clang-format, which is a C++ formatter.

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for suggestion. I'll check clang-format.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.