Go To Line Number in Visual Studio Code

If you want to go to a specific line number in a file, there are a couple of ways to do that with Visual Studio Code, depending on whether you’re already in that file or not.

Same File

Go To Line in the same file.

If you’ve got a file already open and want to hop to a specific line number in it, just use the handy Go To Line shortcut – that is Ctrl+G (Windows/Linux) or Control+G (Mac). Then you just enter the line number in the prompt.

Different File

Going to a specific line in another file.

If you want to go to a specific line in another file, i.e. one you don’t already have open in front of you, there are a couple of things you can do.

The first is to open that file and use the same “Go To Line” in the previous section. There are several ways to open the file, but the quickest is probably to use the handy Ctrl+P (Windows/Linux) or Command+P (Mac) to search for the filename.

The second way is to enter the line number along with the filename in the same Ctrl+P/Command+P prompt! To do this, type the filename in full, followed by a colon (:), and then the line number. That will open the file at the specified line number.

One thought on “Go To Line Number in Visual Studio Code”

Leave a Reply

Your email address will not be published. Required fields are marked *