Fold / collapse the except code section in sublime text 2

Is there any plugin or shortcut to hide everything except the code section in sublime text 2?

I need to fold everything except the section at a time, Do not fold one section at a time.

Thanks ~

enter image description here

+88
sublimetext2 sublimetext3
Sep 16 '13 at 3:14
source share
5 answers

If you hover over the line numbers, you will see arrows - clicking any of them will reset / change the code

enter image description here

enter image description here

If you want to collapse / expand everything - you can do this by going to editing-> minimize the code and select "collapse all" or "expand all":

enter image description here

+190
Sep 16 '13 at 3:24
source share

In addition to the other answers, you can also add on a level. So for example, looking at the default keyword bindings for fold.

Subblime key bindings default

Find bend key bindings.

searching for fold key bindings in sublime

So, for example, foldall, or flexion level 1, had to hold Ctrl , and then press the sequence k , and then 1 :

enter image description here

Or folding level 2 should hold Ctrl and then press the sequence k and then 2 :

enter image description here

Or expanding all will consist of holding Ctrl and then pressing the sequence k and then 0 or in my default settings I also seem to bind it to the letter j :

enter image description here

Warning.

Pressing Ctrl + k twice deletes a line or the number of lines. But actually you cannot put them one by one on Ctrl + u

+21
Mar 21 '15 at 16:14
source share

One thing you can do is select an exception block other than a regular expression, for example using except(.|\n)*?raise.* In your case. Then you can select Find All in the search bar, then Edit> Code Fold → Fold.
Windows shortcut: Ctrl-Shift- [
Mac shortcut: Cmd-Alt- [

All Except locks will be minimized.

+13
Oct. 15 '13 at 16:17
source share

I know this is an old question, but it still holds a high place in the search results, and none of the answers does what the OP wanted.

  1. select the code you do not want to hide
  2. use "Select" → "Invert Selection" to select the code you want to hide instead
  3. use ctrl + shift + [ or Command + Option + ] to collapse selection (s)

This will leave you with the code you originally selected visible.

+2
Mar 02 '18 at 8:41
source share

Fold and UnFold function or class base for MAC only:

  * Fold: command + K, command + 1 * UnFold: command + K, command + J 
0
May 15 '19 at 5:34
source share



All Articles