505

How can I find a file by name in Visual Studio Code?

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

Nenad
  • 24,809
  • 11
  • 75
  • 93
  • 1
    In Visual studio the shortcut is `[CTRL] + ';'` instead – RBT Apr 28 '17 at 04:04
  • Something similar [here](http://stackoverflow.com/questions/30095376/how-do-i-search-for-files-in-visual-studio-code) – RBT Apr 28 '17 at 04:06
  • 12
    It's Ctr+P. Not Ctr+, – Anand Raja Apr 03 '20 at 11:28
  • 3
    Does this answer your question? [How do I search for files in Visual Studio Code?](https://stackoverflow.com/questions/30095376/how-do-i-search-for-files-in-visual-studio-code) – Anand Raja Apr 03 '20 at 11:30
  • @AnandRaja I had the same discussion some time ago, maybe a year. This question is asking specifically for `Find file by name` functionality from Visual Studio. Question you suggested is more broad. Think also about search-ability, Lot of people search for this. – Nenad Apr 03 '20 at 12:39
  • @AnandRaja Regarding `Ctrl+P` - I am using En-US default configuration for Visual Studio and `Ctrl+P` for me brings Print Dialog. On the other hand `Ctrl+,` brings "omni box". One that finds files, sybols, etc... – Nenad Apr 03 '20 at 16:32
  • @Nenad may be, it may differ depending on the region(geo location). My keyboard is also US based, but geo location is India. – Anand Raja Apr 04 '20 at 16:53
  • @AnandRaja Yes, that could be the reason. Probably `EN-IN` culture in Windows, instead of `EN-US`? – Nenad Apr 05 '20 at 18:22
  • 1
    you can make it with `Explorer Tree` https://stackoverflow.com/a/61460276/2736742 – A. Morel Apr 27 '20 at 14:02

7 Answers7

698

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.

machineghost
  • 33,529
  • 30
  • 159
  • 234
Dick van den Brink
  • 13,690
  • 3
  • 32
  • 43
  • 11
    If you want to change the shortcut, look for `Go to file...` in File > Preferences > Keyboard Shortcuts – Dinei May 10 '17 at 15:11
  • 3
    { "key": "cmd+p", "command": "workbench.action.quickOpenNavigateNextInFilePicker", "when": "inFilesPicker && inQuickOpen" } – gdbj Mar 10 '18 at 21:45
  • 5
    We should notice that `Ctrl+P` opens file in Preview mode. In order to open file in new tab, let's follow https://stackoverflow.com/a/43707807/190309 – anticafe Jul 10 '18 at 07:38
  • 2
    This does not seem to work for me, only already open files show up when searching (they can still be found after closing, but never opened files does not show). – Zitrax Jun 26 '19 at 14:36
  • That is. Additionally you can run Ctrl+K+S to search all shortcuts – lyolikaa Jul 23 '19 at 08:40
  • anyone knows why it is the letter "P" ? knowing what it stands for helps remembering – Olivvv Nov 05 '19 at 08:54
  • 3
    @Zitrax is right: Ctrl+P [filename] does not work on all files in the Explorer, it only lists files that are already open -- at least when one is using a remote back-end like WSL, etc. The explorer needs a real search tool which works under all conditions. – Stabledog Aug 22 '21 at 13:16
39

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

rajeev pani..
  • 5,387
  • 5
  • 27
  • 35
  • 44
    This is just a longer way around to arrive to exactly the same point as pressing directly `Ctrl + P`. – Nenad Aug 14 '19 at 09:42
  • 1
    It's a shame this does not get more upvotes; this is solving the OP's question, whereas the answer by @Dick both finds the file _and_ opens it, which was not the OP's request. – Mike Williamson Feb 23 '22 at 19:21
26

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"

Kalpesh Popat
  • 1,416
  • 14
  • 12
23

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

Andrei Pokrovsky
  • 3,590
  • 3
  • 26
  • 17
9

You can find all files by name using the 'Search: find in files' function.
This method is helpfull when you want get 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.

Lars
  • 3,022
  • 1
  • 16
  • 28
3

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

Misha Akopov
  • 12,241
  • 27
  • 68
  • 82
Asaf Pinhassi
  • 15,177
  • 12
  • 106
  • 130
  • 2
    By default `Ctrl+Shift+O` is "Go to symbol..." binding. Lists all symbols on the currently open page. – Nenad Dec 18 '19 at 09:23
0

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.

vimuth
  • 5,064
  • 33
  • 79
  • 116
  • 3
    This is filtering functionality in the File Explorer tree. If your file is not already visible (in expanded directory node), it will not show up. In fact, directory containing the file you are looking for, if collapsed, will disappear when you activate the filter (click on the filter icon). – Nenad Aug 22 '22 at 18:26
  • Yes, the unfortunate prerequisite is that the tree has to be fully expanded. Added that caveat. – futursimple Aug 25 '22 at 10:35
  • I don't think this is a good answer for the question. This is much longer and more complicated way to find a file. It's not practical. – Nenad Aug 25 '22 at 12:08
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 26 '22 at 07:25
  • 1
    I'm upvoting this, this is the only answer that helped me after much searching (wondering why the previous "type to filter" functionality was no longer working). In a very large repo and/or certain situations, this is a necessary feature and much more useful than cmd+p. The fact that folders must be expanded is a very annoying drawback, but is not the fault of this poster. And fortunately, they are working on fixing it here: https://github.com/microsoft/vscode/issues/66971 – Michael Liquori Jan 20 '23 at 16:20