question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Prettier on VS Code unfolds my code blocks on save

See original GitHub issue

I’m using Prettier on VS Code with the editor.formatOnSave enabled. Every time I save my javascript file and prettier runs it unfolds all my functions. Is there a way to prevent this from happening?

I have a large javascript file and would like to keep the functions collapsed.

You can see in the GIF below that even adding a blank line unfolds a bunch of my functions.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
CiGitcommented, Feb 27, 2019

editor.foldingStrategy is the setting. experimental setting disappeared tho. It is now enabled by default as of VSCode 1.24

as @cozuya said, setting editor.foldingStrategy to “indentation” is maybe what you are looking for. I’ll close this issue as there is nothing we can really do here. And VSCode seems to handle it already.

6reactions
cozuyacommented, Aug 8, 2018

@CiGit Toggling this from auto to indentation made prettier stop un-folding everything.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Prettier on VS Code unfolds my code blocks on save . How ...
I'm using Prettier on VS Code with the editor.formatOnSave enabled. Every time I save my (js)|| (jsx) file and prettier runs it unfolds...
Read more >
How to enable auto format on save with prettier in VS Code ...
Explainer video about How to enable auto format on save in VS Code (Visual Studio Code ) editor with prettier code formatter extension...
Read more >
VS Code tips — Fold all block comments - YouTube
Today's VS code command: Fold all block commentsCollapse all block comments in the current file. Use the " Unfold all" command to expand...
Read more >
Visual Studio Code Tips and Tricks
VS Code blocks saving the file to prevent overwriting changes that have been made outside of the editor. In order to resolve the...
Read more >
How to quickly collapse code blocks in VSCode
In VSCode terminology, the collapsible code blocks feature is called Fold/Unfold. You can quickly fold a block of code, given that your cursor ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found