Force Xcode to ensure code folding?

I am testing OS X. I have a source file that is heavy with macros and preprocessor tests. I am trying to collapse the code, so I can determine why a particular character is not defined.

According to Apple Foldable and Deploying Source Code , I have to do this through the focus ribbon. This does not work - there is no tape, and the editor does not respond to requests from the menu.

According to Stack Override resetting code to default (and others, for example How to minimize all methods in Xcode? ), I can use hotkeys for this. This also does not work - the editor also ignores them.

enter image description here

I don't have #pragma marks or #regions , so can you set code areas in Xcode? not applicable.

How to force Xcode to collapse code?

+7
xcode xcode9 macos code-folding
source share
2 answers

Inside Xcode 7, the Folding and Unfolding code blocks are set to OFF.

To change this:

  • Select Xcode (top left)
  • Select Settings
  • Go to Text Editing (center)
  • Tick option code folding tape

.

(see below)

.

enter image description here

โˆš

After finishing,

+7
source share

Code warehousing was disabled in Xcode 9 beta 1, which is now working, in Xcode 9 Beta5 according to the beta note: Solved in Xcode 9 beta 5 - IDE

Here's how:

  • Press and hold the โŒ˜ (command) button on the keyboard and move / hover your mouse over any (start or end) curly braces. It will automatically highlight the block area.
  • Hold (hold) โŒ˜ (command) and press the highlighted area. This will allow you to quickly open the menu window with the Fold option.
  • Select Fold from the menu list. It will add your code and display 3 points, folding / closing the entire block.
  • Now, to expand your code block again, release the โŒ˜ (command) button and click on 3 points, folding the block.

For convenience, see this snapshot:

enter image description here


All manual cuts also work.

 Fold โŒฅ โŒ˜ โ† option + command + left arrow Unfold โŒฅ โŒ˜ โ†’ option + command + right arrow Unfold All โŒฅ U option + U Fold Methods & Functions โŒฅ โŒ˜ โ†‘ option + command + up arrow Unfold Methods & Functions โŒฅ โŒ˜ โ†“ option + command + down arrow Fold Comment Blocks โŒƒ โ‡ง โŒ˜ โ†‘ control + shift + command + up Unfold Comment Blocks โŒƒ โ‡ง โŒ˜ โ†“ control + shift + command + down Focus Follows Selection โŒƒ โŒฅ โŒ˜ F control + option + command + F Fold All โŒ˜ โŒฅ โ‡ง โ† command + option + shift + left Unfold All โŒ˜ โŒฅ โ‡ง โ†’ command + option + shift + left 


Options for adding code from the Xcode menu :

Menubar โ–ถ Editor โ–ถ Code folding โ–ถ "Here is a list of code folding options"

Here is a snapshot of ref:

enter image description here

+2
source share

All Articles