Jump to a VS Code line and return to the previous edit location

Control-G opens Go to Line. Control-Minus and Control-Shift-Minus move backward and forward through editor navigation history.

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.

Use line navigation for a precise reference

A line number from a review, error message or colleague is useful when you have already opened the correct file. Confirm the path first, because the same line number can exist in every file in the project. Navigate to the referenced location, then inspect the surrounding code rather than treating one line as the whole explanation.

Use history for the route back

After jumping away to inspect a reference, editor history is often a better return route than manually reconstructing the old position. Back and Forward refer to navigation locations, not to Undo and Redo. They should not be confused with changing the file’s contents or reverting a code edit.

Practise on an unchanged file

Note one location, jump to another line, then navigate back and forward without editing. Watch the cursor and filename as well as the visible scroll position. This separates navigation history from selection history and helps diagnose whether a surprising result came from being in a different editor context.

Documented commands for this workflow

Scroll the table sideways to see every column.

ActionKeysWhen to use it
Jump to a lineControl-GOpen the correct file before using a line-number reference. ↗
Navigate backControl-MinusReturns through editor navigation locations, not edit undo history. ↗
Navigate forwardControl-Shift-MinusRevisits a forward navigation location when one is available. ↗

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