technerd
technerd

Reputation: 14504

Keyboard shortcut to add block comment in Xcode 9?

I am adding documentation to project, but do not find any shortcut to add Block Comment. I have read Markup Formatting Reference guide but not able to find shortcut.

I am using Option ⌥ + Command ⌘ + / to add comment but it adding /// for every line.

    /// Initializer
    ///
    /// - Parameters:
    ///   - userId: User Id
    ///   - userName: User Name
    ///   - applicationVersion: Applicarion Version

    init(_ userId: String, withUserName userName: String, withApplicationVersion applicationVersion: String)

I want to add Block Comment /** ....*/ as below:

/**
 - parameters:
   - cubes: The cubes available for allocation
   - people: The people that require cubes
 */

Upvotes: 4

Views: 1362

Answers (1)

Khushbu Desai
Khushbu Desai

Reputation: 1023

1.Create Automator service using AppleScript

2.Make sure "Output replaces selected text" is checked

3.Enter the following code:

 on run {input, parameters}
 return "/*\n" & (input as string) & "*/"
 end run

Now you can access that service through Xcode - Services menu or giving it a shortcut under System Preferences.

Upvotes: 2

Related Questions