Question: Is there a way to control the indentation + comment leader input, when adding a new line?
Details: I am trying to set
formatoptions-=cro when inserting a new line (in specific syntax region). I tried using the autocommands
InsertCharPre, but both are too generic for my use case and I cannot figure out how to only operate on entering an
<Enter> when in insert and
O when in normal mode.
InsertCharPre does not trigger on new line insertions, and
InsertEnter also triggers on typing
I.) What am I missing? Any pointers will be greatly appreciated. :)
Edit: I forgot to mention, that my intention is to dynamically add/suppress a comment-continuation insertion on new line insertions (depending on the syntax region).
'indentexpr'. You could have a function decide whether to pass control to regular indentation methods or to swallow it. Would require a bit of work to detect everything but it's less hacky than newline fishing, IMO.