Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any shortcut for // MARK: in Xcode like there is for /// <#Description#>?

Is there any keyboard shortcut for '// MARK:' in swift like there is for header doc '/// Description' ?

like image 523
Mr. SS Avatar asked Jun 08 '17 10:06

Mr. SS


2 Answers

No there isn't any shortcuts for the //MARK. However, you can create a code snippet for it and re-use whenever and wherever you want.

Steps:

  • Declare a //MARK statement on top of extension or method
  • Drag the //MARK into the code snippet section (it's to the left of object library section at bottom right part of Xcode) enter image description here
  • You would be asked to create a name for the snippet. Label it appropriately. And that's it.

  • For usage, Drag and drop this snippet anywhere you want

like image 69
Zarif Ahmed Avatar answered Sep 20 '22 15:09

Zarif Ahmed


There is no problem to add it as a code snippet to Xcode.

What you should do is:

  • Type: // MARK: <#Description#>, select it and then drag it to the code snippet in the utilities section:

enter image description here

  • Fill the popup form, as follows:

enter image description here

and that's it!

Usage:

As per the screenshot above, the completion handler shortcut is: 'm'; By typing 'm' in the code area, you should see:

enter image description here

like image 44
Ahmad F Avatar answered Sep 20 '22 15:09

Ahmad F