admin管理员组

文章数量:1279016

What: Is there any way to open files in vscode and have it auto fold code for you?

Why: I only need to see most code a few times before I've memorized it, and at that point a reference with a peeked definition is all I need. Interfaces, classes, and types just take up my realestate. I want more of the most valuable code on the screen at a time. This means I need to hide some or all of the code when files are large.

Ideally: I'd like to just close specific types of code (ex. interfaces) for specific types of files (ex. typescript files) for files larger than arbitrary 55 lines long, but I would settle for just auto folding all code.

What: Is there any way to open files in vscode and have it auto fold code for you?

Why: I only need to see most code a few times before I've memorized it, and at that point a reference with a peeked definition is all I need. Interfaces, classes, and types just take up my realestate. I want more of the most valuable code on the screen at a time. This means I need to hide some or all of the code when files are large.

Ideally: I'd like to just close specific types of code (ex. interfaces) for specific types of files (ex. typescript files) for files larger than arbitrary 55 lines long, but I would settle for just auto folding all code.

Share Improve this question edited Sep 7, 2020 at 6:28 Urasquirrel asked Jun 1, 2018 at 13:41 UrasquirrelUrasquirrel 1,5851 gold badge19 silver badges36 bronze badges 2
  • That does exist, but only for the import section: stackoverflow./a/68503900/6309 – VonC Commented Jul 23, 2021 at 18:53
  • This app seems to be exclusively for this purpose: [marketplace.visualstudio./… – Alex Commented Apr 30, 2022 at 3:15
Add a ment  | 

1 Answer 1

Reset to default 10

As far as I know that is not possible in vanilla vscode.

There is however an extension you might be interested in, which might do the trick for you: https://marketplace.visualstudio./items?itemName=bobmagicii.autofoldyeah

If you haven't tried it yet you might also want to check out "Go to symbol in file..." - it might help you navigate in larger files.

The hotkey for that is mand-shift-o (on mac), if you type a colon afterwards it even sorts it into variables/functions etc.

Anyways - short answer, not possible without an extension.

本文标签: javascriptvscode auto folding on open fileStack Overflow