1

I write text files in markdown format, in Visual Studio Code. I have a powershell script (.ps1) that I use to convert a markdown file (.md) to a pdf file.

Currently, I have to go to the .ps1 file to execute every time I want to generate the pdf-file. I would like to run the .ps1 file without leaving the markdown file, preferably with a hotkey (f5?). Can anyone explain how to do this?

1

1 Answer 1

3

You can achieve this by configuring a custom VS code keybinding.

  1. Open keybindings.json document. To do this, use ctrl+shift+p and then select Preferences: Open Keyboard Shortcuts (JSON).
  2. Create an entry to run your script (see example below).

This example will run the Powershell script C:\Users\paolo\hello-world.ps1 when f5 is pressed:

{
    "key": "f5",
    "command": "workbench.action.terminal.sendSequence",
    "args": { "text": "powershell C:\\Users\\paolo\\hello-world.ps1\u000D" }
}

although do note that f5 is already configured to run debugging, so I wouldn't use that.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.