Remove Objective-C method declaration fluff with Keyboard Maestro
I got the usual Objective-C method declaration:
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
When you reference this method, its proper name is tableView:cellForRowAtIndexPath:
. Removing all the parameter declarations and the return type by hand is really tedious.
I wrote a Keyboard Maestro macro to remedy my pain:
The Regular Expression part, in more detail:
(
(?<=\:) # look behind without for : without matching it,
\([\w\* ]+\) # take method parameter types ...
[\w]+[ ]? # ... and names, including whitespace
|
[\-\+ ]+ # match visibility operator and whitespace
\([\w\* ]+\) # match method's return type
)
Works like a charm.