Regex to split “){” to two lines, retaining indenting

I was quite proud to come up with this, so here’s my first blog post for a while:

Search:
^([^\S\n]*)(.+))\s*{

Replace:
$1$2)\n$1{

and as a bonus:
^([^\S\n]*)}\s*else\s*{
$1}\n$1else\n$1{

NB (2013-09): it seems that the escaping slashes in this post were lost  at some point, I’ve put them back, but not tested!

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.