2

In VSCode, like in every modern code editor, we can fold (hide) functions, classes etc. basing on their scope. But I'd like to extend this behavior for working also in case of multiline JS strings. I have such an object:

const myObject = {
  myKey1: multiline(`

    some

    very

    long

    multiline

    string


  `),
  myKey2: multiline(`

    another

    very

    long

    multiline

    string


  `)
}

Now I can only fold the whole object in VSCode, but I'd like to fold only some chosen multiline string. Is it possible?

Karol Selak
  • 4,248
  • 6
  • 35
  • 65
  • Does this answer your question? [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) – Patrick Jan 31 '20 at 15:02

2 Answers2

3

You can use:

//#region and //#endregion around the section you want to fold in JavaScript/TypeScript.

Patrick
  • 5,526
  • 14
  • 64
  • 101
3

Okay, I found the best solution for me: just to change folding strategy from auto to indentation:

enter image description here

But thanks for your suggestions guys!

Karol Selak
  • 4,248
  • 6
  • 35
  • 65