Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add xcode text macro

Tags:

xcode

How to create custom code completion macros in Xcode. I googled but I don't find anything

for example, when i was '[' xcode add text '[""]'

it can possible ?

like image 828
user3036749 Avatar asked May 19 '26 19:05

user3036749


1 Answers

Update: In Xcode 11 and later, the library is accessed via the + button in the project window's tool bar. Hold the option key as you click the button to make the Library window persistent so that you can drag your snippet into it. There's also an Editor->Create Code Snippet menu item that creates a new snippet from any selected text.

Original answer: It's easy to add your own completions, but this might be one of Xcode's most under appreciated features. Select some text and then drag and drop the selected text in the snippets library in the lower right corner (icon looks like {}):

snippet library

You can then double-click the new snippet to edit the name, completion shortcut, scope, language, etc., as well as the text of the snippet itself. If you want to add tokens for the user to fill in similar to what the built-in snippets do for parameters, denote them as <#yourtoken#> in the snippet text. There's more information in the docs at Creating a Custom Code Snippet.

headerdoc snippet

like image 163
Caleb Avatar answered May 21 '26 17:05

Caleb



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!