Nenad
Nenad

Reputation: 26607

Find a file by name in Visual Studio Code

How can I find a file by name (or path) in Visual Studio Code?

A Visual Studio shortcut I'm used to is CTRL+,, but it does not work here.

Upvotes: 555

Views: 359324

Answers (8)

Lars
Lars

Reputation: 3573

If you're looking for a way to have a persisted list of file names, (for example; when you need to edit files in sequance, where you know the name of the files)
There's a bit of roundabout way to do that.

Use 'Search: find in files' and search for the start of each line

It will produce a list of files that is persisted in search dialog.

  1. start 'Search: find all files' (default CTRL+SHIFT+F)
  2. In the dialog, turn on 'regex'. (the .* in the search bar.)
  3. search for: ^(?<!\n). This regex matches the first line of each file
  4. Add (part of) the filename in 'files to include'. note that this fields support wildcards.
  5. Outputs a list filenames.

Example

To find all tsconfig.json files, including variants like tsconfig.node.json
use the searchterm tsconfig*.json
find all tsconfig files
you can now click through the results to open each file.

'open in editor'

Using 'open in editor' will open the text editor with the each search result, this is list persisted as well, from here you can navigate to each file, remove entries you've processed

open-in-editor

Upvotes: 22

Alexander Pacha
Alexander Pacha

Reputation: 9710

Given that the actual configuration can be different as a result of various extensions, it doesn't seem helpful to give a specific shortcut as answer. While the default shortcut seems to be Cmd + P (on a Mac), you can find out or reconfigure it when navigating to your Settings -> Keyboard Shortcuts and search for Go to File...

Picture of keyboard shortcuts in Visual Studio Code, filtered by the command 'go to file'

In my case, the IntelliJ IDEA Keybindings Extension added the double-shift shortcut which I'm using a lot, coming from a Jetbrains IDE.

Upvotes: 4

futursimple
futursimple

Reputation: 49

According to this Github page, it's now a simple Cmd+F inside the File Explorer tree on Mac (and presumably Ctrl+F on Windows). Found and highlighted all the README.md files I've been working on:

file search results in vscode file explorer pane

2

Caveat: The tree has to be fully expanded for this to work.

Upvotes: 2

Kalpesh Popat
Kalpesh Popat

Reputation: 1526

It is CMD + P (or CTRL + P) by default. However the keyboard bindings may differ according to your preferences.

To know your bindings go to the "Keyboard Shortcuts" settings and search for "Go to File"

Upvotes: 33

Asaf Pinhassi
Asaf Pinhassi

Reputation: 15573

It's Ctrl+Shift+O / Cmd+Shift+O on mac. You can see it if you close all tabs

Upvotes: 2

rajeev pani..
rajeev pani..

Reputation: 5637

Press Ctl+T will open a search box. Delete # symbol and enter your file name.

Upvotes: 50

Dick van den Brink
Dick van den Brink

Reputation: 14499

When you have opened a folder in a workspace you can do Ctrl+P (Cmd+P on Mac) and start typing the filename, or extension to filter the list of filenames

if you have:

  • plugin.ts
  • page.css
  • plugger.ts

You can type css and press enter and it will open the page.css. If you type .ts the list is filtered and contains two items.

Upvotes: 764

Andrei Pokrovsky
Andrei Pokrovsky

Reputation: 3836

I believe the action name is "workbench.action.quickOpen".

Upvotes: 25

Related Questions