Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
The Microsoft Quantum Development Kit (QDK) uses the standard functionality of Visual Studio Code (VS Code), along with language-specific features when you work with .qs or .qasm files. This reference guide describes the main QDK commands in the VS Code Command Palette, along with other features and links to more content. For general VS Code guidance, see the VS Code documentation.
To find QDK commands, select View > Command Palette and enter QDK: or Microsoft Quantum:. Some commands appear only when a supported file or view is active.
Tip
Create custom keyboard shortcuts for VS Code commands by using Keyboard Shortcuts or by pressing Ctrl + K + S. For more information, see Key Bindings for VS Code.
Commands
Many QDK commands for writing and running Q# and OpenQASM programs are only available when a .qs, .qasm, or .qsc file is active. Other commands are always available.
General commands
| Command | Action | Notes | Alternate user action |
|---|---|---|---|
| QDK: Create Q# project | Creates a Q# project in the active folder, including a qsharp.json manifest file and a src subfolder with a default main.qs file. |
For more information about Q# projects, see Working with Q# projects. | In File Explorer, open the shortcut menu for the target folder and select Create Q# project. |
| QDK: Create a Microsoft Quantum notebook | Opens a sample Jupyter Notebook that runs a Q# + Python program and submits a job to Azure Quantum. | For more information about the QDK in Jupyter Notebook, see Submit jobs to Azure Quantum with the QDK Python package. | N/A |
| QDK: Connect to an Azure Quantum workspace | Connects to an Azure Quantum workspace by using your Azure account or a connection string. After you're authenticated, select the Microsoft Quantum icon on the Activity Bar. | For more information about Azure Quantum connections, see Connect to your Azure Quantum workspace. | Hover over Quantum Workspaces and select the + icon. |
| QDK: Open QDK playground | Opens an online folder of Q# and OpenQASM sample programs in File Explorer. Edit and run the programs in the local quantum simulator, and set breakpoints and step through the code with the built-in debugger. | For more information, see the README file in the sample folder. | N/A |
| QDK: Refresh Azure Quantum workspaces | Syncs the latest changes from your connected quantum workspaces. | If there's a connection issue, an alert icon appears next to the workspace name. | Hover over Quantum Workspaces and select the refresh icon. |
| QDK: Create a Microsoft Quantum Python virtual environment | Creates a folder and installs a Python virtual environment with the selected packages. | Available in desktop VS Code, but not VS Code for the Web. | N/A |
| QDK: Bloch sphere | Opens the Bloch sphere visualizer. | For more information, see How to use the Bloch sphere visualizer in the QDK. | N/A |
| QDK: Show Changelog | Opens a changelog in a new tab that shows QDK updates for the current and all previous releases. | The changelog is also available on the open-source QDK GitHub repository. | N/A |
| Microsoft Quantum: Focus on Quantum Workspaces View | Opens the Microsoft Quantum sidebar and focuses the Quantum Workspaces view. | If no workspaces are connected, the view provides an option to connect to an existing workspace. For more information, see Connect to your Azure Quantum workspace. | Select the Microsoft Quantum icon on the Activity Bar, then expand Quantum Workspaces. |
| Microsoft Quantum: Focus on QDK Learning View | Opens the Microsoft Quantum sidebar and focuses the QDK Learning welcome view, where you can select Start learning. | Available in desktop VS Code before you initialize QDK Learning in the workspace. For more information, see QDK Learning overview. | Select the Microsoft Quantum icon on the Activity Bar, then expand QDK Learning. |
| Microsoft Quantum: Focus on Learning View | Opens the Microsoft Quantum sidebar and focuses the Learning view, where you can access courses and continue your progress. | Available in desktop VS Code after you initialize QDK Learning in the workspace. For more information, see QDK Learning overview. | Select the Microsoft Quantum icon on the Activity Bar, then expand Learning. |
Commands available based on the active file type
| Command | Program file types | Action | Notes | Alternate user action |
|---|---|---|---|---|
| QDK: Show circuit | .qs, .qasm |
Shows a circuit diagram for the program before it runs. | For more information, see Visualize quantum circuit diagrams. | Select the code lens option Circuit from the menu next to the entry point operation or above each user-defined operation in the program. |
| QDK: Run file and show histogram | .qs, .qasm |
Runs the current program and shows a histogram of the results in a new pane. | To access the sort and filter options, select the filter icon in the histogram pane. | Select the code lens option Histogram from the menu next to the entry point operation. |
| QDK: Get QIR for current QDK program | .qs, .qasm |
Opens the QIR source for the current Q# or OpenQASM code in a new edit window. Your program must use the Base, Adaptive RI, or Adaptive RIF target profile to export QIR source. | For more information about QIR, see Quantum intermediate representation and the QDK developer blog. | N/A |
| QDK: Calculate Resource Estimates | .qs, .qasm |
Runs the built-in version of the resource estimator. The VS Code extension uses a deprecated version of the resource estimator. | For more information, see Introduction to the Microsoft Quantum resource estimator. | N/A |
| QDK: Help | .qs |
Opens a brief overview of the QDK extension in VS Code. | N/A | N/A |
| QDK: Run file and show circuit diagram | .qs, .qasm |
Runs the current program and shows a circuit diagram of the program with outputs. | For more information, see Visualize quantum circuit diagrams. | N/A |
| QDK: Show API documentation | .qs |
Opens the API documentation in a new pane. To search this pane, press Ctrl + F. | For more information, see the Q# API reference. | N/A |
| Debug: Start Debugging | .qs, .qasm, .qsc |
Opens the current program in the debugger. | For more information, see Debugging and testing your quantum code. | Press F5, select the code lens option Debug next to the entry point operation, or select the Run icon in the upper-right corner and then select Start Debugging. |
| QDK: Run program | .qs, .qasm, .qsc |
Runs the current program in the default quantum simulator. | For more information, see Get started with Q# programs. | Press Ctrl + F5, select the code lens option Run next to the entry point operation, or select the Run icon in the upper-right corner and then select Run. |
Panel views
Q# and OpenQASM programs use the following views in the VS Code panel:
| View | Action |
|---|---|
| Debug console | Shows run output or debug output |
| Problems | Shows precompile error checks |
Edit Q# and OpenQASM code
Most common code editing features in VS Code are also available for Q# and OpenQASM programs:
- Precompile error checks
- Go-to definition
- References
- Function signatures
- Parameter information
- Completion suggestions, including context-aware, namespace member, and type member completions
- Linting. For Q# files, configure linting per project in the manifest file. For more information, see Working with Q# projects.
For more information, see IntelliSense in the VS Code documentation.
Common tasks
The following tables list commands for common tasks in the QDK extension.
Work with Q# files and projects
| Task | Action | Notes |
|---|---|---|
| Create a new Q# file | Select File > New file > Text file. Save the file with a .qs extension. |
If you set Files: Default Language = qsharp, new files automatically default to Q# formatting. |
| Create a Q# project | From an open folder in File Explorer, select QDK: Create Q# project from the Command Palette. Or, open the shortcut menu for the folder in File Explorer and select Create Q# project. | For more information about Q# projects, see Working with Q# projects. |
| Create a sample file | In a blank .qs or .qasm file, enter samples, and then select a sample program from the list. |
You can also select QDK: Open QDK playground in the Command Palette to open an online folder of Q# and OpenQASM sample programs in File Explorer. |
Connect to Azure Quantum
| Task | Action | Notes | Alternate user action |
|---|---|---|---|
| Connect to an Azure Quantum workspace | Select the Microsoft Quantum icon on the Activity Bar. From Quantum Workspaces, select Connect to an existing workspace. Follow the prompts to select a subscription and workspace. | You can connect to multiple workspaces. Select + next to Quantum Workspaces to connect another workspace. Workspace connections persist between your VS Code sessions. | From the Command Palette, select QDK: Connect to an Azure Quantum workspace. |
| Connect programmatically with a Python program | Open the shortcut menu for an existing workspace connection and select Copy Python code to connect to workspace. Paste the resulting code into your Python program. | For more information, see Submit jobs to Azure Quantum with the QDK Python package. | N/A |
Run programs
| Task | Action | Notes | Alternate user action |
|---|---|---|---|
| Run a Q# or OpenQASM program on the local quantum simulator | In a .qs or .qasm file, select the Run icon in the upper-right corner, and then select Run. |
For more information on the quantum simulator, see the Sparse quantum simulator. | Press Ctrl + F5, or choose either QDK: Run file and show histogram or QDK: Run file and show circuit diagram in the Command Palette, or choose the Run code lens option above the entry point operation. |
| Debug a program | In a Q# or OpenQASM program, select the Run icon in the upper-right corner, and then select Start Debugging. | For more information about the Q# debugger in VS Code, see Debugging and testing your quantum code. | Press F5, or choose the code Debug code lens from the menu above the entry point operation. |
| View providers and targets in your workspaces | Select the Microsoft Quantum icon on the Activity Bar. From Quantum Workspaces, expand the workspace, and then expand Providers to see the available providers in the workspace. Expand an individual provider to view the available targets. | Hover over a target name to view its Status and Queue time before you submit a job. | N/A |
| Submit a job to Azure Quantum | With a Q# or OpenQASM program open, select a workspace, provider, and target. To submit the current program, select the arrow next to the target. | For more information, see Submit jobs to Azure Quantum with the QDK extension for VS Code. | N/A |
| View job results | Expand the workspace, and then expand Jobs. To open the job output from Azure Storage, select the cloud icon next to the job name. | Jobs are listed from newest to oldest. | N/A |