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?

Update The problem is solved by using:

set cinoptions=t0

Thank Vivian De Smedt for the solution.

  • 1
    What do you get when you query :set cindent?, :set smartindent?, :set autoindent? and :set indentexpr??
    – Friedrich
    Feb 24 at 11:36
  • 1
    I can reproduce the problem with autoindent, cindent, nosmartindent, indentexpr=. Feb 24 at 11:50
  • @Friedrich The result looks like what Vivian De Smedt shows
    – Rekkhan
    Feb 24 at 12:45
  • This is because @VivianDeSmedt was kind enough to do the digging for you and tried all permutations of relevant indentation options. I wouldn't have done this (and as a matter of fact: I didn't).
    – Friedrich
    Feb 24 at 13:29

1 Answer 1


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

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

Your Answer

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

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