How can I make vim align the ternary ?: operator nicely?

Viewed 1321

I like to write code using the ternary ?: operator like this:

std::string result = input.empty() ? createNewItem()
                                   : processInput( input );

How can I configure vim so that when pressing Return after having typed createNewItem() indents the next line so that the cursor is in the same column as the last ? so that I can just continue typing : processInput( input );?

I tried looking at the cinoptions-values setting but I didn't see anything relevant.

2 Answers
Related