how to set a default file as the first file to run in visual studio code?

  • Last Update :
  • Techknowledgy :

I'm assuming you have a launch configuration in launch.json that looks something like this:

{
   "name": "Python: Current File (Integrated Terminal)",
   "type": "python",
   "request": "launch",
   "program": "${file}",
   "console": "integratedTerminal"
}

Suggestion : 2

To open the Settings editor, use the following VS Code menu command:,On Windows/Linux - File > Preferences > Settings,You can also open the Settings editor from the Command Palette (⇧⌘P (Windows, Linux Ctrl+Shift+P)) with Preferences: Open Settings or use the keyboard shortcut (⌘, (Windows, Linux Ctrl+,)).,You can edit via the Settings editor Workspace tab or open that tab directly with the Preferences: Open Workspace Settings command.

As an example, lets change the editor line number color. Click the Edit in settings.json link and add the following JSON:

     "workbench.colorCustomizations": {
        "editorLineNumber.foreground": "#00ff00"
     }

The following example can be pasted into a settings JSON file to customize editor settings for the typescript and markdown language modes.

{
   "[typescript]": {
      "editor.formatOnSave": true,
      "editor.formatOnPaste": true
   },
   "[markdown]": {
      "editor.formatOnSave": true,
      "editor.wordWrap": "on",
      "editor.renderWhitespace": "all",
      "editor.acceptSuggestionOnEnter": "off"
   }
}

For example, workbench.colorCustomizations takes an Object that specifies a group of UI elements and their desired colors. If your user settings set the editor backgrounds to blue and green:

  "workbench.colorCustomizations": {
     "editor.background": "#000088",
     "editor.selectionBackground": "#008800"
  }

The result, when that workspace is open, is the combination of those two color customizations, as if you had specified:

  "workbench.colorCustomizations": {
     "editor.background": "#000088",
     "editor.selectionBackground": "#00FF00",
     "editor.foreground": "#880000"
  }

Suggestion : 3

07/05/2022

Some systems are set up to require validation of all code signatures. You may receive the following error:

Language server startup failed.

This problem can occur when PowerShell's execution policy is set by Windows Group Policy. To manually approve PowerShell Editor Services and the PowerShell extension for VS Code, open a PowerShell prompt and run the following command:

Import - Module $HOME\.vscode\ extensions\ ms - vscode.powershell * \modules\ PowerShellEditorServices\ PowerShellEditorServices.psd1

After reading the documentation, you can add configuration settings in settings.json.

{
   "editor.renderWhitespace": "all",
   "editor.renderControlCharacters": true,
   "files.trimTrailingWhitespace": true,
   "files.encoding": "utf8bom",
   "files.autoGuessEncoding": true
}

Add an item to the list powershell.powerShellAdditionalExePaths or create the list if it doesn't exist in your settings.json:

{
   // other settings...

   "powershell.powerShellAdditionalExePaths": [{
      "exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
      "versionName": "Downloaded PowerShell"
   }],

   // other settings...
}

To set the default PowerShell version, set the value powershell.powerShellDefaultVersion to the text displayed in the session menu (also known as the versionName):

{
   // other settings...

   "powershell.powerShellAdditionalExePaths": [{
      "exePath": "C:\\Users\\tyler\\Downloads\\PowerShell\\pwsh.exe",
      "versionName": "Downloaded PowerShell"
   }],

   "powershell.powerShellDefaultVersion": "Downloaded PowerShell",

   // other settings...
}