Table of Contents
Custom shortcut keys (optional)
Frequently Asked Questions and Precautions
Home Development Tools VSCode How to add a breakpoint with a shortcut in VS Code?

How to add a breakpoint with a shortcut in VS Code?

Jul 19, 2025 am 02:14 AM

In VS Code, the most direct shortcut key to adding breakpoints is F9, press to add or remove breakpoints for the current line; 1. The default shortcut key is F9, and you need to ensure that the cursor is located in the target line; 2. You can search for "Preferences: Open Keyboard Shortcuts" through the command panel (Ctrl Shift P or Cmd Shift P) to find the "Toggle Breakpoint" custom shortcuts; 3. Common problems include file types that do not support, debugging environment is not configured, or shortcut key conflicts. It is recommended to try clicking the breakpoint first to confirm whether the debugging environment is normal.

How to add a breakpoint with a shortcut in VS Code?

In VS Code, the most direct way to add breakpoints is to click on the blank area next to the line number of the code. But if you prefer to use shortcut keys, you can actually complete this operation efficiently.

How to add a breakpoint with a shortcut in VS Code?

The default shortcut key is F9

VS Code provides us with the default shortcut to quickly add or remove breakpoints: press F9 to add breakpoints to the currently selected line of code; if there is a breakpoint on the line, press F9 again to delete it.

It should be noted that this shortcut key only works when your cursor is on a certain line.

How to add a breakpoint with a shortcut in VS Code?

Custom shortcut keys (optional)

If you are used to using other key combinations, or F9 is not convenient on your keyboard, you can customize the shortcuts for this feature:

  • Open the command panel: Ctrl Shift P or Cmd Shift P
  • Enter "Preferences: Open Keyboard Shortcuts" and select
  • Search keywords: "Toggle Breakpoint"
  • Click the pencil icon on the right side of the corresponding line and enter the new shortcut key you want.

For example, some people like to bind to combinations such as Ctrl F9 or Alt B , it depends on your own habits.

How to add a breakpoint with a shortcut in VS Code?

Frequently Asked Questions and Precautions

Sometimes you will find that pressing F9 does not respond, which may be because:

  • The current file is not a language type supported by debugging (for example, you are editing a .txt file)
  • The debugging configuration is not activated (you need to set up launch.json first)
  • Shortcut keys are conflicted by the system or other software (especially some function keys on Mac need to be used with Fn)

If you encounter this situation, you can try to add a breakpoint with the mouse click to see if it is displayed normally. If the mouse is also invalid, it may be that the debugging environment is not configured properly, not the shortcut keys.


Basically that's it. Using F9 is the fastest way, and it is easier than the mouse after getting familiar with it.

The above is the detailed content of How to add a breakpoint with a shortcut in VS Code?. For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

VS Code shortcut to focus on explorer panel VS Code shortcut to focus on explorer panel Aug 08, 2025 am 04:00 AM

In VSCode, you can quickly switch the panel and editing area through shortcut keys. To jump to the left Explorer panel, use Ctrl Shift E (Windows/Linux) or Cmd Shift E (Mac); return to the editing area to use Ctrl ` or Esc or Ctrl 1~9. Compared to mouse operation, keyboard shortcuts are more efficient and do not interrupt the encoding rhythm. Other tips include: Ctrl KCtrl E Focus Search Box, F2 Rename File, Delete File, Enter Open File, Arrow Key Expand/Collapse Folder.

How to set a default formatter in vscode? How to set a default formatter in vscode? Aug 03, 2025 am 06:32 AM

InstallthedesiredformatterextensionlikePrettierorBlack.2.SetthedefaultformatterforalanguageviaSettingsUIorCommandPalette,ordirectlyinsettings.jsonusingthecorrectformatterID.3.Optionallyenableformatonsavebysetting"editor.formatOnSave":truegl

What are the correct launch.json settings for debugging a C   application with GDB on Linux? What are the correct launch.json settings for debugging a C application with GDB on Linux? Aug 04, 2025 am 03:46 AM

TodebugaC applicationusingGDBinVisualStudioCode,configurethelaunch.jsonfilecorrectly;keysettingsincludespecifyingtheexecutablepathwith"program",setting"MIMode"to"gdb"and"type"to"cppdbg",using"ex

How to debug a Python script in VSCode How to debug a Python script in VSCode Aug 16, 2025 am 02:53 AM

To debug Python scripts, you need to first install the Python extension and configure the interpreter, then create a launch.json file to set the debugging configuration, then set a breakpoint in the code and press F5 to start the debugging. The script will be paused at the breakpoint, allowing checking variables and step-by-step execution. Finally, by checking the problem by viewing the console output, adding logs or adjusting parameters, etc., to ensure that the debugging process is simple and efficient after the environment is correct.

How to install a specific version of a VSCode extension How to install a specific version of a VSCode extension Aug 06, 2025 pm 01:18 PM

To install a specific version of the VSCode extension, it must be installed through the CLI and .vsix file. 1. Get the extension ID (such as ms-python.python); 2. View available versions via https://marketplace.visualstudio.com/_apis/public/gallery/publishers/{publisher}/vsextensions/{extension}/versions; 3. Use https://marketplace.visualstudio.com/_apis/public/gallery/

How to use the output panel in vscode? How to use the output panel in vscode? Aug 03, 2025 am 05:47 AM

Press Ctrl Shift U (Windows/Linux) or Cmd Shift U (macOS) to open the output panel; 2. It can also be opened through the "Switch Output" command in the view menu or command panel; 3. Use the drop-down menu in the upper right corner to switch different output sources such as extensions, Git, tasks, etc.; 4. Use this panel when debugging extension problems, viewing task results, checking Git operations, or troubleshooting startup failures; 5. You can efficiently utilize panel information by clearing logs, enabling automatic scrolling, copying content, etc.; 6. Some logs are only displayed when VSCode starts, and the panel needs to be opened in advance to diagnose problems; 7. The output panel is a key tool for viewing VSCode background information, which is extremely good when problems occur.

How to use the timeline view for local history in VS Code How to use the timeline view for local history in VS Code Aug 20, 2025 am 07:22 AM

TheTimelineviewinVSCodeprovidesaccesstolocalhistoryfortrackingandrestoringfilechangeswithoutGit;1)OpenafileandclickitinFileExplorertorevealtheTimeline;2)Viewtimestampedlocalhistoryentriescreatedonsave;3)Clickanentrytopreviewchangesindiffeditor;4)Righ

How to automatically format Python code in VSCode How to automatically format Python code in VSCode Aug 14, 2025 pm 04:10 PM

ToautomaticallyformatPythoncodeinVSCode,installBlackusingpipinstallblack,installtheofficialMicrosoftPythonextension,setBlackastheformatterinsettings.jsonwith"python.formatting.provider":"black",enableformatonsavebyadding"edit

See all articles