Fix bug and improve indentation.

This PR fixes a bug inserting parenthesis instead of curly brackets, and adds indentation when inserting a newline.