I'm looking for a way to make the following possible in Xcode (26.0 or later):
I select one or more lines of code. I then enter a hotkey (or select a menu item) that results in adding the line:
#ifdef SOME_MACRO
before the selection and adding the line:
#endif
after the selection.
Example:
Start with the following lines of code:
BOOL x = NO;
int y = 4;
NSString *str = @"Hello";
If I then highlight the int y = 4; line and use the proper hotkey or menu, the result would be:
BOOL x = NO;
#ifdef SOME_MACRO
int y = 4;
#endif
NSString *str = @"Hello";
Is something like this possible in Xcode?
I looked at code snippets but that doesn't seem to support wrapping existing code.
I looked at the Xcode Settings under Editor and Shortcuts and didn't see a way to add such a custom shortcut.