Opens an external site in a new window
Mental Health Awareness Month
โ€œCommunityโ€
RODNEY LAB
  • Home
  • Plus +
  • Newsletter
  • Links
  • Profile
RODNEY LAB
  • Home
  • Plus +
  • Newsletter
  • Links

VS Code File Nesting: Collapse Files to Declutter # VS Code File Nesting: Collapse Files to Declutter #

blurry low resolution placeholder image VS Code File Nesting
  1. Home Rodney Lab Home
  2. Blog Posts Rodney Lab Blog Posts
  3. SvelteKit SvelteKit Blog Posts
<PREVIOUS POST
NEXT POST >
LATEST POST >>

VS Code File Nesting: Collapse Files to Declutter #

Published: 3 years ago
3 minute read
Gunning Fog Index: 5.4
Content by Rodney
blurry low resolution placeholder image Author Image: Rodney from Rodney Lab
SHARE:

๐Ÿ“‚ VS Code File Nesting #

VS Code file nesting is a relatively new feature which helps make your VS Code explorer look a little tidier. It does that by letting you collapse some related files into groups. For example, the default config will nest an NPM package-lock.json file under the package.json file in your JavaScript projects. The lock file is then hidden from view by default, but you can easily expand it from under package.json with a single click. The defaults are pretty limited.

In this video, we see how you can add a quite comprehensive config which will get your VS Code tidy for most projects. Then, we see how you can extend even the comprehensive list to fit your own edge cases.

If thatโ€™s what you wanted to know, then hit play on the video! After that, donโ€™t forget to scroll down. You will see a list of resources mentioned in the video. Drop a comment below or reach out for a chat on Element  as well as Twitter @mention  if you have suggestions for improvements or questions.

๐Ÿ“น SvelteKit Port: Video #

Please enable JavaScript to watch the video ๐Ÿ“ผ

VS Code File Nesting: Collapse Files to Declutter

๐Ÿ—ณ Poll #

What do you use most for code editing?
Voting reveals latest results.

๐Ÿ–ฅ SvelteKit Port: Code #

Example per-project configuration to nest example.css.ts under example.svelte:

    
1 {
2 "editor.formatOnSave": true,
3 "explorer.fileNesting.patterns": {
4 "*.svelte": "${capture}.css.ts"
5 },
6 "[markdown]": {
7 "editor.wordWrap": "bounded",
8 "editor.wordWrapColumn": 80,
9 "editor.quickSuggestions": false
10 },
11 "[svelte]": {
12 "editor.defaultFormatter": "svelte.svelte-vscode"
13 }
14 }

๐Ÿ”— VS Code File Nesting: Links #

  • Post on the SvelteKit TypeScript vanilla-extract starter,
  • Anthony Fu's VS Code file nesting config ,
  • VS Code Explorer File Nesting Introduction ,
  • Remix docs on styling components with vanilla CSS ,
  • Twitter handle: @askRodney ,
  • Element chat: #Rodney matrix chat .

๐Ÿ VS Code File Nesting: Summary #

How can you declutter the VS Code explorer? #

The VS Code explorer (which lists all files and folders in a project) can get pretty congested quite quickly. This is because many modern tooling utilities each add one or two config files to your project. On top, you might have a unit test file or CSS styling file alongside the source file containing the logic. Much of the time you just want to find the source with the logic. The other files can slow you down in finding the source you want. Using explorer file nesting in VS Code you can collapse the tooling config files into related groups. On top, you can nest button.css or button.test.css under button.js. This helps you find button.js quicker. Also, because there is less clutter, you will be able to access the collapsed, nested files quicker.

How do you extend VS Code file nesting defaults? #

You can extend VS Code file nesting defaults by editing the JSON preferences file. To open it up use Cmd (or Ctrl), Shift and P then search for `Preferences: Open Settings (JSON)`. In there you need to add `explorer.fileNesting` settings. We have seen Anthony Fu's vscode-file-nesting-config GitHub repo has a pretty comprehensive config which you can just paste in here. You can then edit the settings to suit your own personal edge cases. By the same token, you can add extra lines for new tools or languages which are not yet included in Anthony's config.

How do add VS Code file nesting config to a single project? #

We have seen you can create a `settings.json` file within a `.vscode` folder in the root of a project. In `settings.json` there you can add `explorer.fileNesting` settings which you just need on this project. Also, if you share the project, for example in a Git repo, then anyone who clones it and opens it in VS Code can use your settings. Handy when working in a team!

๐Ÿ™๐Ÿฝ Feedback #

If you have found this video useful, see links below for further related content on this site. I do hope you learned one new thing from the video. Let me know if there are any ways I can improve on it. I hope you will use the code or starter in your own projects. Be sure to share your work on Twitter, giving me a mention, so I can see what you did. Finally, be sure to let me know ideas for other short videos you would like to see. Read on to find ways to get in touch, further below. If you have found this post useful, even though you can only afford even a tiny contribution, please consider supporting me through Buy me a Coffee.

blurry low resolution placeholder image ask Rodney X (formerly Twitter) avatar

Rodney

@askRodney

Just recorded a new video talking through this in more detail.

You see how to customise VSCode for all projects and also add config on a project-by-project basis.

We also see a ๐Ÿ‘จ๐Ÿฝโ€๐Ÿณ vanilla-extract โค๏ธ Svelte example.

Hope you find it useful!

#SvelteJS https://t.co/LuxTqXPlTC

โ€” Rodney (@askRodney) May 30, 2022

Finally, feel free to share the post on your social media accounts for all your followers who will find it useful. As well as leaving a comment below, you can get in touch via @askRodney on Twitter and also askRodney on Telegram . Also, see further ways to get in touch with Rodney Lab. I post regularly on SvelteKit as well as Search Engine Optimization among other topics. Also, subscribe to the newsletter to keep up-to-date with our latest projects.

Thanks for reading this post. I hope you found it valuable. Please get in touch with your feedback and suggestions for posts you would like to see. Read more about me โ€ฆ

blurry low resolution placeholder image Rodney from Rodney Lab
TAGS:
SVELTEKIT
<PREVIOUS POST
NEXT POST >
LATEST POST >>

Leave a comment โ€ฆ

Your information will be handled in line with our Privacy Policy .

Ask for more

1 Nov 2022 โ€” Astro Server-Side Rendering: Edge Search Site
3 Oct 2022 โ€” Svelte eCommerce Site: SvelteKit Snipcart Storefront
1 Sept 2022 โ€” Get Started with SvelteKit Headless WordPress

Copyright ยฉ 2020โ€‰โ€“โ€‰2025 Rodney Johnson. All Rights Reserved. Please read important copyright and intellectual property information.

  • Home
  • Profile
  • Plus +
  • Newsletter
  • Contact
  • Links
  • Terms of Use
  • Privacy Policy
We use cookies  to enhance visitorsโ€™ experience. Please click the โ€œOptionsโ€ button to make your choice.โ€‚ Learn more here.