I need to change my coding style of putting opening braces in same line to new line. I need to find and replace the (space){ with (newline){. I heard using regular expression fi
You could try the following:
control+q is needed to quote the return key. There’s no visual feedback for typing control+q return, so the only visible character in the replace box is the opening curly brace:
Although this answers your question, there’s (at least!) one problem: it won’t indent the opening curly brace, so something like
- (void)method {
for (obj in collection) {
NSLog(@"%@", obj);
}
}
is converted to
- (void)method
{
for (obj in collection)
{
NSLog(@"%@", obj);
}
}
The menu item Edit > Format > Re-Indent will place the opening curly braces in the correct indentation tab but there might be non-desired side effects to your code style.
Edit: as commented in the other answer, you might want a regular expression that matches an arbitrary number of whitespaces surrounding the curly brace, e.g. \s*{\s*$