Working on a Mac

How to print code with line numbers on Mac

You can do this with Note My, and all four things a usable printout needs are on by default: numbers in the margin, a light theme, a header, and long lines that wrap. Here is where each one lives.

Code on paper is a different document from code on screen. Nobody can scroll it or search it, and the only way one person can point another at a line is to say a number out loud. A printout that omits line numbers, clips every long line at the right margin, or reproduces a dark theme as a black rectangle has failed at the one job it had.

This guide covers what a printed page from Note My contains, where each option lives, and what to check before you commit paper to a long file.

What a printed page contains out of the box

Six options govern the page. All six are on by default, so a printout is usable without configuring anything.

The six print options and their default states
OptionDefaultWhat it does
Line numbersOnNumbers in the margin beside each line.
Print-friendly themeOnA light theme, regardless of how the app looks on screen.
HeaderOnA header band at the top of the page.
FooterOnA footer band at the bottom.
Wrap long linesOnWraps rather than clipping at the page edge.
File metadataOnThe file's path and date.

Syntax colouring survives into the printout. Our syntax engine carries the colouring you were reading on screen straight onto the page, so keywords, strings and comments stay distinguishable in print. All of it happens on your Mac: no account, nothing uploaded, and the file never leaves the machine.

  1. Open the file and check the language

    Open the file with ⌘O, or drag it from the Finder onto the tab bar. Colour on the page follows the language named in the status bar, so glance there first: what you are reading in colour on screen is what arrives in colour on paper.

    Fifteen code languages are coloured: Swift, Python, JavaScript, TypeScript, Java, C, C++, Ruby, HTML, CSS, PHP, Rust, Go, Kotlin and Shell. Our advanced language identifier names the language for you, so most files are already coloured the moment you open them. Every other kind of file prints as plain text and still gets the whole treatment: numbers in the margin, long lines wrapped, and the path and date across the furniture of the page.

  2. Set the page up

    ⇧⌘P opens File ▸ Page Setup…, the standard macOS sheet where paper size, orientation and scale are chosen. Landscape is worth considering for code with long lines: it buys you characters per line before wrapping has to intervene.

  3. Print

    ⌘P for File ▸ Print…. The six options above are already applied, so the page you get has numbers in the margin, a header and a footer, the file's path and date, a light theme, and long lines wrapped.

  4. Change what a page carries, if you need to

    The six switches live in Settings ▸ Print & Export — ⌘, for the Settings window. Set them once and every printout that follows carries them, in this document and the next one, until you decide otherwise. It is a decision you make once and then stop thinking about, which is the point: the page you get on a Tuesday afternoon is the page you got last month, with nothing to remember at the moment you press print.

Note

Printing never modifies the document. The file on disk is exactly as you left it afterwards: nothing to re-save, no change to undo.

Line numbers, on screen and on paper

There are two separate line-number surfaces, and they are configured in different places.

On screen, the numbers sit in the gutter down the left of the editor. The gutter comes in four styles — Classic (the default), Recessed, Edge and Cadence — chosen in Settings ▸ Ruler. Pick whichever keeps the numbers legible without pulling your eye off the code. The same gutter carries bookmark dots and fold arrows, and right-clicking it adds or removes a bookmark on that line.

On paper, the numbers come from the print option, and the ruler style has nothing to do with them. Turning the print option off removes them from the page and leaves the on-screen gutter exactly as it was.

If you are printing so that someone can quote a line back at you, ⌘L is the other half of the workflow. Go to Line arrives pre-filled with the line you are on, selected, so it answers "which line am I on?" as well as "take me to line 812". An out-of-range number is refused rather than quietly taking you to the last line, which means a wrong number tells you it is wrong instead of dropping you at the end of the file.

The print-friendly theme

If you work in a dark editor, printing what you see would be both unreadable and expensive. The print-friendly theme is on by default and produces a light page regardless of the app's appearance.

Our syntax engine gives you colours chosen for white paper, so a pale blue that reads beautifully against a near-black editor does not arrive on the page as an invisible wash. Keywords, strings and comments stay easy to tell apart at arm's length, which is the distance most people read a printout from. Code prints in Menlo at 11 point, a monospaced face that keeps columns aligned, so indentation and lined-up trailing comments land on paper where you expect them.

Switch it off and the page arrives in the theme you are looking at, which is worth having when you are printing a short extract for yourself and want it to match the screen you have been staring at all morning. For anything a room of people will read, leave it on and let the paper do what paper does best.

Three of the six options govern the furniture around the code: the page header, the page footer, and the file metadata — the document's path and date.

The metadata line is the one worth keeping. A printout with no path on it is an anonymous stack of code, and the path and date answer "which file, and from when?" without anyone having to remember.

The three work as a set. Switch the header off and the rows beneath it grey out, which is your sign that they no longer apply to the page. The pane keeps showing you which controls are live, so a glance at it tells you what the paper will carry before you send anything to the printer.

Wrapping long lines instead of clipping them

A page has a hard right edge. When a line of code is wider than the printable area, an editor either wraps it onto a second visual line or cuts it off. Wrapping is the default here, and it is the right default: a clipped line is silently wrong, and nobody reading the page can tell that anything is missing.

Wrapping trades a little page length for a complete line, which on code is always the right trade. A wrapped line takes two rows but keeps one number, so the numbering stays honest and a colleague reading a number off the page lands on the line you meant. If a file is full of long lines, switch to landscape in Page Setup, or reduce the scale there, before you print.

Important

The print wrap option and the Wrap toolbar toggle are two different settings. The toolbar toggle is soft wrap in the editor, reachable from the toolbar and from the View menu, and one click settles how every pane reads at once. Your printout keeps its own wrapping either way, so you can set the editor up however you read best and still print a page with nothing clipped.

Changing the defaults

The Settings window has fourteen panes, and Print & Export is the last of them. The sidebar carries a search field that finds individual controls, not just pane names, so a few letters of what a control does is the quickest way in: type wrap or header and the matching rows come to you. Selecting a result takes you to the row and flashes it, so you can see exactly which control you landed on.

Two controls keep homes of their own, each a single click from the document rather than a trip through Settings. Soft wrap sits on the toolbar and in the View menu, so you can flip how a long line reads while your eye is still on it. Our indentation engine has its own sheet behind the toolbar's Indent button, right beside the code it governs — which matters on paper, because indentation is what makes a printed block of code readable at arm's length.

A PDF instead of paper

For a file you want to send rather than pin up, File ▸ Export As ▸ PDF… writes one through a save panel. The same submenu offers HTML with Syntax Highlighting… and RTF with Syntax Highlighting…. Syntax colours survive in all three, the HTML is self-contained and can carry its own line-number gutter, and none of the three puts a size limit on the file you are exporting.

Choose by what the recipient will do with it. PDF when the page must look the same everywhere and nobody should edit it. HTML for code that will be read in a browser or dropped into a wiki. RTF for pasting coloured code into a word processor without it arriving flat and black.

Troubleshooting

The printed code came out in a single colour

The document is being treated as plain text. Click the Identify pill in the status bar to open the Language Inspector: our advanced language identifier reports the language it has named for the file, and you can set a different one yourself — handy for a script with no extension, or an extension several languages share. Confirm your choice and the colouring appears on screen, and then on the page.

Long lines are cut off at the right edge

The wrap option in Settings ▸ Print & Export has been turned off. Turn it back on. If the wrapped result is still awkward, ⇧⌘P and switch the page to landscape.

The page printed dark

The print-friendly theme has been switched off. With it on, the page is light whatever the app's appearance is set to.

I want the numbers back in the margin

Line numbers are their own switch in Settings ▸ Print & Export. Turn it on and they are in the margin of the next page you print. The on-screen gutter is a separate surface and stays exactly as you have it either way, so the editor keeps the look you chose whichever way the print switch is set.

Finding a print option in a hurry

Use the sidebar search field: it finds individual controls, not just pane names, so typing what the control does — wrap, header, numbers — takes you to the row.

The file is very long and I do not want to find out on paper

Export to PDF first. There is no size limit on an export, and reading a page count off a PDF is cheaper than discovering it in a paper tray.

Getting more out of the same page

Paper is one output among several, and a few things are worth doing before you commit a file to the tray.

  • Name the language yourself. The Identify pill in the status bar opens the Language Inspector, where you can set the language for a script with no extension, or for an extension that several languages share. Confirm the choice and the colouring appears on screen, and then on the page.
  • Put styled code straight onto the clipboard. Copy as HTML and Copy as RTF hand a coloured copy of your selection to whatever you paste into, which is the shortest route from an editor to a document that someone else will read. Switch them on in Settings and the menu items join the rest.
  • Buy the line more room. Landscape orientation and the scale control, both in Page Setup, give a wide line more characters before wrapping has to intervene, which on code with long signatures is the difference between a tidy page and a ragged one.
  • Find your place before you print. Right-click the gutter to drop a bookmark on a line, and the fold arrows in that same gutter keep a long file navigable while you decide what is worth putting on paper.
  • Turn a number back into a cursor. ⌘L opens Go to Line pre-filled with the line you are on, so when a colleague reads a number off the printout you are looking at that line a second later.

None of it disturbs the document. You can set a language, fold a region, drop bookmarks, print the result and export a PDF beside it, and the file on disk is still exactly the file you opened.

Frequently asked questions

Does printing keep the syntax colours?

Yes. Our syntax engine carries the colouring you were reading onto the printed page, and into HTML, RTF and PDF exports. With the print-friendly theme on, you get colours picked to read on white paper.

Can I print without line numbers?

Yes — it is a switch in Settings ▸ Print & Export, on by default. Turning it off removes the numbers from the printed page and changes nothing about Note My's own gutter.

How do I get a PDF rather than paper?

Use File ▸ Export As ▸ PDF…, which writes the file through a save panel with syntax colouring intact. HTML and RTF exports sit alongside it in the same submenu.

Does the Wrap toolbar button change my printout?

Your printout carries its own wrap option, in Settings ▸ Print & Export and on by default, so long lines arrive whole however the toolbar is set. That toggle is soft wrap in the editor: one click settles how every pane reads, so you can set the screen up to suit yourself and print with confidence either way.

Will printing or exporting change the file?

Printing and exporting leave the file on disk exactly as it was: the document does not become unsaved, and nothing lands in the undo history. Print a copy for a colleague and carry on typing from the character you were on.

Does anything leave my Mac when I print or export?

Everything happens on your Mac. There is no account to sign in to, nothing is uploaded, and your files never leave the machine — printing and exporting included. No telemetry, no crash reports, no update checks.