You could try the following:
- In the Find box, type space \ { $
- In the Replace box, type control+q return {
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*$