Insert characters after the cursor on auto-indentation

Is there a way to insert characters after the cursor while doing auto-indentation in CM5? Specifically, given

def f(

I would like to insert a newline after the cursor on ENTER, i.e.

def f(

You could write your own command that does this, and bind it to Enter. The library doesn’t come with such a command.

Thanks for a quick reply @marijn! Is there any existing command I could use as an example or should I just find the implementation of auto-indentation and start there?