Is there any keyboard shortcut for '// MARK:' in swift like there is for header doc '/// Description' ?
3 Answers
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:
- Fill the popup form, as follows:
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:

- 30,560
- 17
- 97
- 143
-
Thanks so much. That completion shortcut is absolutely brilliant. – Erik van der Neut Mar 21 '21 at 00:32
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)
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

- 343
- 2
- 9
There is one Command we have to use before any function or Methods or top of Coding line.
COMMAND + OPTION + /
If It is top of collectionView methods it will be like
// MARK: - CollectionView Methods
extension HomeViewController: UICollectionViewDelegate, UICollectionViewDataSource,UICollectionViewDelegateFlowLayout {
/// Collection Views for Fetured, Popular, Categories
///
/// - Parameters:
/// - collectionView: Data to be provided by service. Collection Views are categoriesCollectionView, popularCollectionView, feturedCollectionView
/// - section: retturn Value from Service
/// - Returns: return Value from Service
func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
return homeList.count
}

- 272
- 3
- 14