DEV Community

Gregor Martynus
Gregor Martynus

Posted on

6

VS Code ProTip™: paste path of active file into terminal

I need to use the path to the current active file in my VS Code editor all. The. Time!

Eventually I figured there must be a shortcut but there is none that's built-in. However, you can quickly add it yourself.

  1. Open the command palette (Windows: Ctrl+Shift+P, Mac: Command+Shift+P)
  2. Search for "Preferences: Open Keyboard Shortcuts (JSON)"
  3. In the opened keybindings.json file, add a new item to the array
  {
    "key": "ctrl+shift+t",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "${relativeFile}" },
    "when": "terminalFocus"
  }
Enter fullscreen mode Exit fullscreen mode

Now open any file, then open a terminal within VS Code, and press Ctrl+Shift+T and it will paste the full path to that file where your cursor is in the terminal.

Top comments (0)

Billboard image

Create up to 10 Postgres Databases on Neon's free plan.

If you're starting a new project, Neon has got your databases covered. No credit cards. No trials. No getting in your way.

Try Neon for Free →

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay