I want to perform auto-formatting on a certain code block, after a specific character has been typed, similar to visual studio’s auto-formatting.
For example, when an endline character has been typed, the previous line could be formatted, like one were hitting Vgq on that line.
What is the easiest and most efficient way to achieve this?
I already thought about using the InsertCharPre event, but I actually would need a InsertCharPost event. Unfortunately that doesn’t exist.
if
format code blockyou meant isgq, you could try:this mapping does: when you type Enter in INSERT mode, it will does automatically
vgqfor you, and place cursor in next line, staying in INSERT mode.Hope it is what you are looking for.