I used to use clang-format for code generation kind of stuff.
Instead of using templates I would use macros to generate code like: sort functions or linked-list functions.
Then I would run the compiler preprocessor on the macros and take the output and feed it to clang-format.
It is the poor man approach for meta-programming. It is slow but it is handy and does the job.
However, what you are showing is not similar to what 4coder is trying to do from what _I understand_.
The idea in the long terms is to have code editing rather than text editing meaning the program understand whether the cursor is on statement, expression, argument and then you would say for example: "make for loop", "wrap selection in for loop", "delete statement" or "remove parameter" and you will map these commands to your own shortcuts. Also because it understand your code it will render it as "blocks" rather than text meaning it doesn't matter how many spaces there are or how many newlines there are or whether the statement is broken into two lines it will just be rendered according to the user configurations. Also moving the cursor is now more clever as Casey was saying.
The source code representation inside the editor will be something like the AST (what the compiler make when it parses the code) not text buffer. And when you save the file it will convert it back to text.
This is _my understanding_ of Allen's goals for 4coder from watching his streams. And I am not/cannot speak for him.
His streams and demos are on
YouTube.