Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change comment Indentation Xcode

Tags:

xcode

The default behaviour for the Xcode comment keyboard shortcut is to place // at the far left of the selected lines regardless of indentation.

I'd like to change this so that the indentation is taken into account and the // is inserted just before the text to comment.

For example:

class MyClass {
    func myFunc() {
//        cmd-/ does this
        // I want cmd-/ to do this
    }
}

Is this possible?

like image 936
doovers Avatar asked Nov 10 '15 22:11

doovers


1 Answers

You can use the Comment Here extension. After downloading:

  1. Restart Xcode
  2. Go to Xcode -> preferences -> key bindings
  3. Search for "Comment Selection" and remove the key binding for it
  4. Search for "Comment Here" and add the key binding "command /" for the toggle comments option.
  5. Your comments are now pretty :)
like image 140
Eric Wiener Avatar answered Sep 22 '22 06:09

Eric Wiener