How to Jump to a Specific Line in VS Code
Navigating through large code files in Visual Studio Code (VS Code) can be time-consuming if you rely solely on scrolling. Fortunately, VS Code provides several built-in shortcuts and methods to instantly jump to any specific line number. This guide covers the fastest ways to navigate directly to a line using keyboard shortcuts, the Command Palette, and the status bar.
Method 1: The Go to Line Keyboard Shortcut (Fastest)
The quickest way to jump to a specific line in VS Code is by using the dedicated “Go to Line” keyboard shortcut.
- Press Ctrl + G on Windows/Linux, or Ctrl + G on macOS.
- A small input box will appear at the top of the window with a colon
(
:) already typed. - Type the line number you want to reach.
- Press Enter to instantly move your cursor to that line.
Method 2: Using the Quick Open Menu
If you are already using the Quick Open menu to search for files, you can transition directly into jumping to a line.
- Open the Quick Open menu by pressing Ctrl + P on Windows/Linux or Cmd + P on macOS.
- Type a colon (
:) followed immediately by the line number (for example,:42). - Press Enter to jump to that line.
Note: You can also use this to open a specific file and jump to a
line simultaneously by typing the filename, a colon, and the line number
(e.g., app.js:42).
Method 3: Using the Status Bar
If you prefer using your mouse, you can trigger the search input directly from the editor’s status bar.
- Look at the bottom-right corner of your VS Code window.
- Click on the section that displays the current line and column numbers (it usually looks like Ln X, Col Y).
- The “Go to Line” input box will open at the top of your screen.
- Type your target line number and press Enter.