Do you want to find a file in VSCode? Developers usually work with large, complex projects, that’s when they need to quickly look up for files using its name. In this short article, you’re going to learn how to quickly open a file inside a project given the filename in VSCode.
Find files by name in VSCode
Suppose you’re opening a folder/directory in a VSCode workspace, you can quickly open a file given its filename. Simply press Ctrl + P keyboard combination to bring up the Quick Open input box and start typing. On macOS, you can press the Command ⌘ key instead of Ctrl.
The search is case insensitive and you can even type in parts of the filename to match it. Below is an example which "mds" search query matches "models.py".
At this point, you can use Arrow keys to move up and down in the list, press Enter to open any files you want. Alternatively, keep pressing Ctrl + P will go down the file list and automatically open the file whenever you release the button without any additional action.
If you’ve opened the VSCode Command Palette (using Ctrl + Shift + P), you can also delete the > symbol at the beginning of the input box and it would become the Quick Open box where you can search for files.
Change keyboard shortcut to search for files
You can change the shortcut to open the Quick Open input box by modifying workbench.action.quickOpen
setting.
First, in a VSCode window, open Keyboard Shortcuts preferences by selecting File > Preferences > Keyboard Shortcuts (or press Ctrl + K followed by Ctrl + S). Alternatively, you can open Command Palette (using Ctrl + Shift + P) and type in "Keyboard Shortcuts" to achieve the same result.
In the Keyboard Shortcuts tab, search for workbench.action.quickOpen
setting. In order to change its hotkey, double click in the corresponding Keybinding column and press the new hotkey.
We hope that the information above is useful to you. If you’re interested in advanced editing features of VSCode, check out our post on how to enable/disable word wrap in VSCode, How to use LaTeX in VSCode or how to automatically indent your code in Visual Studio Code.