1

I have piece of sample code (copied from stack overflow)

//some lines of code

    template <typename ... Args>
std::string string_format (
        const std::string& format,
        Args ... args )
{
    int size_s = std::snprintf( nullptr, 0, format.c_str(), args ... ) + 1;
    if( size_s <= 0 ){ throw std::runtime_error( "Error during formatting." ); }
    auto size = static_cast<size_t>( size_s );
    std::unique_ptr<char[]> buf( new char[ size ] );
    std::snprintf( buf.get(), size, format.c_str(), args ... );
    return std::string( buf.get(), buf.get() + size - 1 );
}

For some reason, the line containing "template" is always indented.

How to stop this behavior?

I can see some relevant settings as follows: I can reproduce the problem with autoindent, cindent, nosmartindent, and indentexpr=.


Update The problem is solved by using:

set cinoptions=t0

Thank Vivian De Smedt for the solution.

0

1 Answer 1

2

You can control the cindent indentation using the cinoptions (:help cinoptions).

To not have the return type indented you can do:

set cinoptions=t0

More information with :help cino-t

2
  • Thank you. It works!
    – Rekkhan
    Feb 24, 2023 at 12:48
  • You are Welcome :-) Thanks for the feedback. Feb 24, 2023 at 12:55

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.