9

Notepad++ has commands to fold/unfold all the document. Is that possible to select some of the lines and fold/unfold only the blocks lying inside the selection?

EDIT1

Any notepad++ plugin which enables this capability?

Eduardo Poço
  • 2,819
  • 1
  • 19
  • 27

6 Answers6

6

Sorry but Notepad++ don't haves that option.

It has a similar option called "Hide lines"

  1. Select the text you want to hide
  2. Right button click
  3. Select Hide Lines.

Instead of a + symbol you will see two blue arrows showing there are some lines hidden.

NetVicious
  • 3,848
  • 1
  • 33
  • 47
  • 1
    Well, I want the lines inside the blocks to be invisible, but I need the first and last lines of each block to be visible, so I know there is a block there. I just don't want the details to clutter the view. – Eduardo Poço Sep 13 '16 at 18:21
  • 2
    I know what you need, but Notepad++ don't has that option. Just don't select first and last line of the block you want to hide using my answer ;-) – NetVicious Sep 14 '16 at 08:19
  • I would have to do it to each block, so it will be the same as folding one by one – Eduardo Poço Sep 14 '16 at 13:45
4

Notepad++ folding mechanism detects parts of the documents that are enclosed in braces {}. Whatever lines are enclosed in braces can be folded and unfolded using the '+' and '-' handles on the left, next to line numbers. You can have nested folds as well!

Pranav
  • 74
  • 7
  • 3
    No, I do not want to click every +/- symbol, I want to select some lines and do the folding/unfolding of those parts automatically. – Eduardo Poço Sep 06 '16 at 22:00
  • 4
    how about `view > Fold all (alt-0)` or `view > Unfold all (alt-shift-0)` to fold or unfold all in selection? Also for more control can also use `View > Collapse Current Level` or `View > Uncollapse Current Level` – Joshua Klein Sep 13 '16 at 20:58
  • 2
    fold/unfold all works on the whole document regardless of selection – Eduardo Poço Sep 14 '16 at 13:51
  • 2
    Old post, but @JoshuaKlein was on the right track. Click inside the node you want to collapse and then choose View > Collapse Current Level. That's not the selected area, but it's a heck of a lot closer than clicking every single '-' icon. – StevoInco Feb 06 '18 at 14:38
2

Ctrl-clicking a fold point (+/-) will recursively unfold/fold all blocks inside it.

1

Change the Language to C# or Java or JavaScript to enable collapsing comments and brackets.

  1. Menu option: Language - C - C# (or use shortcut - Alt, L, C, C, Enter)

  2. Then try these out:

     /*hello
     hello
     */
    
     {hello
     hello
     }
    
Suraj Rao
  • 29,388
  • 11
  • 94
  • 103
0

I have discovered that, if your code blocks are folded and you hit Enter and then select Undo, NPP will unfold only the code block where the cursor is. I use this trick in macros.

Bob G
  • 1
0

Save the file as a .cs and use {} as the beginning and ending of each section you wish to collapse.