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.
Inspired by a roughly similiar question I exercised my vimscript-fu and created a little script to do this job:
I saved this file as
vimfiles/indent/after/cpp.vimand addedfiletype indent onto my.vimrcto toggle loading of indentation plugins. It seems to work good enough!