Exclude files from Quick File Navigation in VS Code

Quick File Navigation is one of the most used features of Visual Studio Code. When working in a relatively large project, you might be taking extra time to navigate the list to skip files you never intend to open, or worse selecting the wrong file by accident.

I’ve considered this a minor issue in my workflow for a while, but overtime small issues like this add up and ultimately take a lot more time than one may realized. This was certainly the case for me, so I decided to take a few minutes to finally fix it!

Honestly, I should have done this much earlier in the project because it’s so easy to configure. My current project uses TypeScript and my goal is to hide the compiled JavaScript files from the list.

Quick File Navigation in Visual Studio Code

To do this, open the Workspace Settings file:

Windows

  • Shortcut: Ctrl + ,
  • File Menu: File > Preferences > Settings

Mac

  • Shortcut: Cmd + ,
  • Menu: Code > Preferences > Settings

By default, you’ll most likely be looking at User Settings. In the top right, make sure that Workspace Settings is selected.

Settings in Visual Studio Code

In the search field, type search.exclude and you’ll see a setting by this exact name. As the name suggests, this setting exclude files from the search, in my case, all JavaScript files.

I simply copied the setting from default file (comment + default values) and pasted it in my settings file on the right and added a glob pattern for all JavaScript files.

// Configure glob patterns for excluding files and folders in searches. Inherits all glob patterns from the files.exclude setting.
"search.exclude": {
"**/node_modules": true,
"**/bower_components": true,
"**/*.js": true
}

Now when I use Quick File Navigation, JavaScript files are omitted from the list.Easy, am I right? If you found this useful, be sure to share it with others!

Quick File Navigation in Visual Studio Code

 

If you have any VS Code tips I’d love to hear them! Email or Tweet me @justinhhorner.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s