Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code - How to open a file by its full path in the command palette?

I need some functions like:

VS Code -> F1 (open Command Palette) -> OpenFileFeature: /home/user/blablabla/code.py -> (Enter) -> (file opened in editor)

In this case /home/user/blablabla/code.py can be an external file (relative to my current folder open in VS Code).

Does anyone know some tricks about this?

like image 382
Sergej Matsypa Avatar asked Sep 07 '25 22:09

Sergej Matsypa


1 Answers

In vscode you can use the command palette to open files via absolute path using the CTRL + P shortcut. Please note the difference. CTRL + P opens the file navigator whereas CTRL + SHIFT + P opens the editor command window, meaning you will see the > indicator. Additional note - you could just simply delete the > identifier as well, if using the command shortcut.

The file navigator takes absolute paths as arguments, once you filled out a file that exists it will populate in the drop down list for selection: screenshot

Notice how I do not have any workspaces open so there is no navigation history or relative file association.


Alternatively,

There is naturally the option to open via CTRL + O, where you can always enter absolute paths as well, not a command palette related answer but related option.

like image 172
soulshined Avatar answered Sep 09 '25 22:09

soulshined