How to go to a line number on Mac
You can do this with Note My — here is the shortcut, what the dialog does that most people miss, and the several other ways a line number reaches you in the first place.
A compiler stops at line 4,217. A linter flags line 63. A stack trace names a line in a file you have not opened this year. A folder-wide search returns forty hits and each one is a line number. Every one of those is the same small problem: you have a number, and you need to be standing on that line.
This guide covers how to jump to a line in Note My, what the dialog does that is easy to miss, where line numbers come from when nothing has handed you one, and the places the editor takes you to a line without your typing anything at all.
Jump to a line
-
Open Go to Line
Press ⌘L, or choose Search ▸ Go to Line…. There is also a Go to Line button in the toolbar — it opens exactly the same thing.
-
Type the number
A small sheet appears over the window reading "Enter a line number between 1 and N", where N is the number of lines in the document. The field is already filled in with the line your caret is on, and the text is already selected — so typing replaces it. You do not need to clear the field first.
-
Confirm
Press ↩. The view scrolls to that line and the line flashes before settling. The ruler draws a band on the current line, so you can see where you landed.
The field arrives pre-filled with your current line, so opening Go to Line and cancelling it is a quick way to answer "which line am I on?" without moving anything.
Why you can trust the line you land on
Ask for line 90,000 in a 51,000-line file and you are told, rather than moved somewhere that merely looks right. You get a beep instead of a jump. The field takes the line number itself, and that is what keeps every jump exact.
That is the right call. Sliding quietly to the last line looks helpful and is not: paste a number from a stack trace, get taken to the end of the file, and you will read the wrong line believing it is the right one. A beep tells you at once that the number and the file do not match — usually because you are in the wrong file, or an older copy of it. The answer is the information.
The message carries the fact you need, too: "Enter a line number between 1 and N" tells you how many lines the document actually has. One keystroke, and you know both where you are going and how far the file runs.
Finding the number when nothing has given you one
Half the time the number is not the problem — knowing where you are is. Three things answer that.
The line-number gutter
Every line is numbered down the left edge, and the ruler comes in four styles: Classic (the default), Recessed, Edge and Cadence, chosen in Settings ▸ Ruler. They differ in how strongly the current-line band and the accent bar are drawn, so if the current line is hard to pick out, changing style is the fix.
The gutter carries more than numbers. Bookmark dots and fold arrows live there too, and right-clicking a line offers a single item that flips between "Add Bookmark to Line N" and "Remove Bookmark from Line N" — which is also a quick way to read a line number off the screen.
The Lines counter
The status bar carries six counters — Chars, Words, Spaces, Lines, Sel and Occ. Lines is the total for the document, which is the N in the Go to Line message. Read it before you trust a number somebody else gave you: if a stack trace names line 4,217 and the counter says 900, you are in the wrong file.
The counters keep pace as you edit and always describe the tab in front of you, so moving between documents never leaves you reading another file's numbers.
Arriving at a line without typing a number
Several parts of the app hand you a line rather than asking for one. If any of these fits, it beats copying a number by hand.
| Where you start | How you get to the line |
|---|---|
| A folder-wide search | Search ▸ Find in Folder… (⇧⌘F). Results appear grouped by file, each row a line number and a trimmed preview. Double-click a row to open that file at that line; an already-open file has its tab activated instead. |
| A log full of errors | ⌥⌘E and ⌥⇧⌘E jump to the next and previous error. A HUD reports "Jumped to line N.", so you get the number as well as the position. |
| Lines you marked earlier | ⌘F2 toggles a bookmark on the current line; F2 and ⇧F2 step forward and back through them. Bookmark All Search Matches (⌥⌘B) turns a search result into a set of marked lines you can walk. |
| Malformed JSON | Edit ▸ Validate JSON reports the failure with (around line N, column M). Take the N to ⌘L. |
| A file comparison | Our comparison view lists differing lines in a table of Document, Line and Content. Click a row and the line flashes in both panes. |
| Hidden characters | Our hidden-character scanner lists every finding with its Line:Col in the Review All sheet under Clean ▸ Clean Invisible / Special Characters…. Double-click a finding to reveal it in the editor. |
| A selection you scrolled away from | ⌘J — Jump to Selection — scrolls back to whatever is selected. |
Go to Line inside a macro
Go to Line is one of the actions our macro recorder records, which makes "go to line 12, do something, go to line 40, do the same" a thing you record once.
Start with ⌥⌘R, perform the moves and edits, stop with ⌥⇧⌘R. Alongside Go to Line it records typing, deletion, paste, navigation, selection, find, replace, save, encoding and line-ending conversion, bookmark toggling and tab renaming. Play back with ⌥⌘P, or use Playback Multiple Times… for 1 to 9,999 iterations — ask for more than 50 and you are asked to confirm first.
Two things make this safe to try. A recording indicator stays on screen while you work — a pulsing red dot, the words Recording Macro and a running count of the actions captured — so you can watch the recording take shape as you make it. And a whole playback run comes undone in one step — a single ⌘Z puts the document back as it was, however many iterations you asked for.
A recorded jump replays the number you recorded, which is exactly what you want for a fixed layout — the tenth line of every file in a batch, say. When the content matters more than the position, record a search for the text instead: find is one of the actions that records, so playback lands on that text wherever it has since moved to.
Troubleshooting
I hear a beep instead of a jump
That is the document telling you the number and the file do not agree. Read the sheet: it names the highest line the document has. If that is much smaller than what you typed, you are in a different file from the one the error came from, or an older copy of it. Take a fresh number, or open the file the tool was actually looking at, and the same keystroke will land.
The line number from my tool does not match what I see
Two ordinary causes. Either the file changed after the tool ran — re-run it and take a fresh number — or the tool counted from zero while Note My counts from one, in which case everything is off by exactly one line.
⌘L is not opening the dialog
Go to Line works on the document in front of you. If you are still on the welcome screen, open a file with ⌘O or press ⌘N for a new one, and the shortcut answers straight away.
The current line is hard to pick out in the gutter
The current-line band is drawn differently in each of the four ruler styles. Try Settings ▸ Ruler and switch between Classic, Recessed, Edge and Cadence — the difference is deliberate and one of them will suit your display better than the others.
The Lines count is still rising on a file I just opened
Give it a moment. Our large-file engine means you are not kept waiting on a very large file — the window is usable straight away, so you can read, scroll and search while the total is still arriving. If a number does not land on a file you have only just opened, watch the Lines counter until it stops moving, then try again. It is worth doing this before you conclude a number is wrong, since a total that has not settled yet will make a perfectly good line number look out of range.
With a very large file open the status bar marks it as one, so you always know what you are working with and can read the counter with that in mind. Nothing about the size of a file changes where it lives, either — a multi-megabyte log stays on your Mac and is never uploaded anywhere.
I need to land on a particular column
Two quick routes. Jump to the line, then walk across it with the arrow keys — holding ⌥ moves a word at a time, which covers most of a line in a few presses. Or skip the number entirely and search for the text you are after, which puts the caret on the exact characters rather than on a position you have to count your way to.
Keeping your place once you are there
Landing on a line is half the job. Staying in touch with it while you work is the other half, and four small habits make that effortless.
- Mark it. ⌘F2 drops a bookmark on the current line and a dot in the gutter beside it. From then on F2 and ⇧F2 walk forward and back through your marks, so a line you were sent to an hour ago is one keystroke away however far you have wandered since.
- Turn a search into a route. Bookmark All Search Matches (⌥⌘B) marks every hit at once. Forty results stop being a list you keep scrolling back to and become a set of stops you step through with the same two keys.
- Come back to it. Scroll away from a selection and ⌘J brings the view back to it. What is selected stays selected, so you can wander off to check something and pick up mid-edit.
- See it clearly. The ruler draws a band on the line you are on, and the four styles in Settings ▸ Ruler vary how strongly that band reads. On a bright display, or in a dense file, switching style is the quickest way to make your position obvious at a glance.
There is one more worth knowing when the number has to leave your screen. File ▸ Print… (⌘P) carries line numbers onto the page, so a printed copy or a PDF shows the same numbers you have been working with. Quote line 4,217 to a colleague and it means the same thing on their desk as it does on your Mac.
Everything on this page happens on your Mac. Nothing is uploaded, there is no account to make, and a file you open, search or navigate never leaves the machine.
Frequently asked questions
What is the go to line shortcut on a Mac text editor?
In Note My it is ⌘L, and the same command sits in the Search menu as Go to Line… and as a toolbar button. The field opens pre-filled with the line you are on, selected, so you can type straight over it.
What happens if I ask for a line the file does not have?
You are told, which is the useful answer. If you paste line 90,000 from a stack trace into a file that has 51,000 lines, being taken quietly to line 51,000 looks like success and is not — you would read the wrong line and believe it. The beep, plus the sheet naming the highest line the document has, tells you straight away that you are in a different file or an older copy of it.
How do I find line 5,000 in a very large file?
The same way as any other line — ⌘L, type 5000, press ↩. It is the same dialog and the same jump: the field arrives pre-filled and selected, you type over it, and you land. Our large-file engine keeps a multi-megabyte log open and workable, so you can scroll it, search it and jump around it while you work. On a file you have only just opened, give the Lines counter in the status bar a moment to settle before you conclude a number is out of range.
Do line numbers appear when I print the file?
Yes. File ▸ Print… (⌘P) includes line numbers by default, along with a print-friendly light theme, a header, a footer, wrapped long lines and file metadata. Each is a switch you can turn off.
How do I jump straight to an error line in a log?
Use ⌥⌘E and ⌥⇧⌘E for the next and previous error. They stop on the usual severity words — FATAL, CRITICAL, SEVERE, ERROR, WARNING and WARN — whatever their case, wrap around at the end of the file, and report "Jumped to line N." so you get the number as well as the position.
Can I record going to a line as part of a repeatable edit?
Yes. Our macro recorder records Go to Line along with typing, navigation, find, replace, save and bookmark actions. Record with ⌥⌘R, stop with ⌥⇧⌘R, play back with ⌥⌘P. A whole run comes undone in one step, so a single ⌘Z reverses it.