Is there a quick way to fold and unfold comments in xcode 7?

752 Views Asked by At

Is there a quick way to fold and unfold a block of comments in xcode 7?

While I'm trying out new code I like to keep different versions of a "solution" until I decide which one is my favorite and delete the rejected material.

2

There are 2 best solutions below

1
Daniel Asher On BEST ANSWER

Code-folding block comments does not work in Xcode 7 - 7.2.1 in Swift files.

You can, however, hack it by using an empty closure to surround the comments. This will also work with multiple line comments too.

_ = { /* Comment
      myCommented.code
      */ }

Definitely a hack, but could save you lots of scrolling around.

1
ChrisHaze On

The ability to Fold & Unfold code blocks is set to OFF within Xcode 7.

Steps to change this:

  1. Select Xcode (top left)
  2. Choose Preferences
  3. Navigate to Text Editing (center)
  4. Tick the option Code folding ribbon

Once you've done this, you'll be able to collapse the comments, along with blocks of code.

I hope this helps!

.

Added Picture Reference

enter image description here