Xcode to wrap selected text in curly braces "{}"

Any Xcode shortcut for wrapping text in opening and closing brackets - {} , () or []?

Fatigue is growing from the removal of "}", which Xcode automatically enters after entering the type "{" in cases where I have already received the code in the editor, which wants to be inside new brackets.

+5
source share
3 answers

Here is the user of the Xcode script, which should not destroy new lines in the text.

#!/usr/bin/python
#
# Wraps selection in braces.
# Set Input to "Selection".
# Set Output to "Replace Selection".

tabChar = '\t' # Replace with spaces if desired
input = '''%%%{PBXSelectedText}%%%'''

print "{"
for line in input.splitlines():
  print tabChar + line
print "}"

script Input Variables Xcode Workspace Guide %%%{PBXSelectedText}%%% .

EDIT: ​​ , . . , , Xcode, .

+2

Apple has released Tech Q & A regarding this. Alas, it does not handle closing kinky, but still it seems better than moving the entire selected code to one line.

0
source

All Articles