I'm using spacemacs with vim-bindings, but I only mention it so you don't scratch your head too long at the keystrokes of the macro. A regular emacs solution will work just the same.
I've read through the naming and saving section of the manual. This is nice but it's a lot of steps and the output is verbose and unpleasing to the eye:
(fset 'insert-code-block
(kmacro-lambda-form [?o ?\{ return ?\} escape ?O escape] 0 "%d"))
I've also read this post with similar naming.
I would like to use something like kbd
syntax:
(kbd "o { RET } <escape> O")
For reference, this was the keychord binding I used with regular emacs:
(key-chord-define-global "xb" (kbd "RET { RET RET } C-p TAB"))