Tuesday, February 2, 2016

Code folding and unfolding in XCode 7.2

In the previous version of XCode, there was a little down arrow beside the source code editor for folding or unfolding the code. But in the new version of the XCode (7.2) that little arrow does not exist. It is very annoying to scroll up and down to find out the method which we are searching. On the other hand  the code editor looks really messy with unfolded code.

In new XCode there are two ways to code folding or unfolding. First of them is selecting these option from menu bar. Second one is using shortcut key. I prefer the last one. For me it is irritating to use the mouse continually while I am coding.

For the first process put the cursor on the method block which you want to fold or unfold then follow the following steps

 XCode menu -->  Editor --> Code folding --> then select folding option.

Image 1 : Code folding options from XCode Menu bar.

From Image 1 you can see the shortcut keys for all kind of code folding option.
  1. Fold : Option + Command + ←
  2. Unfold : Option + Command + →
  3. Fold Methods & Functions : Option + Shift + Command+ ←
  4. Unfold Methods & Functions : Option + Shift + Command + →
  5. Fold Comment Blocks : Control + Shift + Command + ←
  6. Unfold Comment Blocks : Control + Shift + Command + →
Here, Comment block (In 5,6) means when you are commenting line of code using  /* */ (Image 2). If you use double slash (//) for commenting these shortcut key will not work.
Image 2: Comment Block in XCode.


Another little tip, if you are using windows keyboard with your MAC then use
  • Alt instead of Option
  • Windows Key instead of  Command
  • Ctrl instead of Control


    No comments:

    Post a Comment