In this blog post, I will show you how how to run a selected PowerShell or any code on Visual Studio Code.

In the old days of PowerShell ISE, you had the option to run selected code from the editor into the console using F8.

In VS Code, F8 is used for something else and in the post, I will show you how to change it.

Get Started

Currently, in VS code, we can use the GUI to selected code using the following steps and as shown in the following image.

Select a code from the editor

Click on Terminal from the top menu

Click on Run Selected Text

To configure F8 or another key to run a selected code.

Click on File

From the File menu click on Preferences

And click on Keyboard shortcuts

From the keyboard shortcuts menu type

“run selected.”

Click on the Run selected command

From the Keybedding menu, type F8.

If the F8 key is in use, you will have the option to see which command is using it and change it to something else, once you do it go back to the menu and set the command again.

After completing the change, you will see that the F8 key is set as the Keybinding key.


Posted

in

by