5

I want to fold the following lines of code in VSCode

x = np.linspace(0, 20, 100)
plt.plot(x, np.sin(x))
plt.show()

How do I do this? ctrl + shift + [ only collapses functions.

user2653663
  • 2,818
  • 1
  • 18
  • 22
  • 9
    You can use `#region` and `#endregion` to mark a region which can be folded: https://code.visualstudio.com/docs/editor/codebasics#_folding – UnholySheep Dec 22 '18 at 15:32
  • Possible duplicate of [How do I collapse sections of code in Visual Studio Code for Windows?](https://stackoverflow.com/questions/30067767/how-do-i-collapse-sections-of-code-in-visual-studio-code-for-windows) – Mark Dec 22 '18 at 16:47
  • Can I use folding without explecitily write #region #endregion ? so just any comment maybe #anything then I can make region? – Nur Afrizal Bashri Dec 23 '18 at 00:33
  • @NurAfrizalBashri no, you must specify the markers, otherwise you're asking for the extension to just guess that you happen to think it's a region that should be foldable. – Brett Cannon Jan 03 '19 at 22:52

1 Answers1

4

you can try this free extension: Region Folding for VsCode

is very usefull

Ale DC
  • 1,646
  • 13
  • 20