Open VSCode action button on toolbar

English support forum

Moderators: petermad, Stefan2, white, Hacker

Post Reply
quazi
Junior Member
Junior Member
Posts: 19
Joined: 2021-05-12, 10:05 UTC

Open VSCode action button on toolbar

Post by *quazi »

I am trying to configure VSCode to open in current directory. Like a project. Also if some file under cursor present I want to open it directly.
Should be something like

Code: Select all

Command: C:\Program Files\Microsoft VS Code\Code.exe
Parameters: -r . %P%N
But %P%N always resolves into something (even if it ..). Any way to fix it?
User avatar
sqa_wizard
Power Member
Power Member
Posts: 3970
Joined: 2003-02-06, 11:41 UTC
Location: Germany

Re: Open VSCode action button on toolbar

Post by *sqa_wizard »

What is the reason to open VSCode in current directory?

To open file under cursor just use:

Code: Select all

Parameters: -r %P%N
To open file under cursor using current directory as data directory:

Code: Select all

Parameters: -r --user-data-dir "%P" %P%N
#5767 Personal license
quazi
Junior Member
Junior Member
Posts: 19
Joined: 2021-05-12, 10:05 UTC

Re: Open VSCode action button on toolbar

Post by *quazi »

Current directory - is a minimal project. With readme, docker-compose.yml, some logs for example. So I want to open current project or docker-compose.yml directly. If I open docker-compose.yml as a file, VSCode can't match file with directory and ignores settings in current .vscode/ so I can't use .vscode/tasks.json and can't quick switch between files in current directory as VSCode shows "No folder opened" in Explorer bar.
The question is not about current dir (just dot is enough) but about optional selected filename
larry99
Junior Member
Junior Member
Posts: 77
Joined: 2009-01-16, 16:03 UTC
Location: Germany

Re: Open VSCode action button on toolbar

Post by *larry99 »

When I had to solve a similar problem i used an itermediate batch file. You can pass the current dir and file name and build your vscode command line as needed.
Post Reply