Comment VS Code lines without confusing line and block comments

Command-/ toggles a line comment; Shift-Option-A toggles a block comment. The active language determines the comment syntax.

Scope
Visual Studio Code · Current vendor documentation checked 3 November 2026; no running-app compatibility test is claimed.
Keyboard and customization
Documented Mac defaults; punctuation and function keys depend on keyboard layout and hardware.. User bindings, app versions, focused controls and installed extensions can change a command. Inspect the active app menu or its shortcut editor when a listed combination differs.
Review basis
Documentation reviewed 2026-11-03 by Codex — primary-documentation and editorial review; no hands-on runtime test. These bindings were not tested in a running app for this guide.

Choose the kind of comment you need

Line comments are useful for a line or a selected range of lines. A block comment is a different syntax form that may surround a text range. Check which language mode is active, because the same editing command can produce different delimiters in different file types.

Inspect the result before saving

Commenting can change the behaviour of executable code. Make sure the selected range is intentional and that nested comment syntax has not created a surprising result. A visually dimmed region is helpful feedback, but it is not a substitute for understanding what remains active in the program.

Use a disposable sample first

Try both commands on a short example in the language you actually use, then toggle back. If the shortcut differs from this documented default, inspect the Keyboard Shortcuts editor and any keymap extension. Punctuation keys such as Slash are especially worth checking on a non-US keyboard layout.

Documented commands for this workflow

Scroll the table sideways to see every column.

ActionKeysWhen to use it
Toggle line commentCommand-/Uses the active language’s line-comment behaviour. ↗
Toggle block commentShift-Option-AWorks where a block-comment action is supported. ↗
Explicitly add line commentsCommand-K, then Command-CA chord useful when you want to add rather than toggle. ↗

Sources and corrections

Found a mismatch? Email pashaseenainc@gmail.com with your app version, macOS version, keyboard layout and the command. Please leave personal document names out.

Keep going

Right there when you need it.

Keep a compact shortcut reference in your Mac’s menu bar.

Explore the native Mac app