How to view code syntax on a Mac
You can do this with Note My. Here is how to open a source file and see it properly coloured, what each colour is actually telling you, and how to give a file the language you want it read as.
You have a file of code in front of you — someone else's script, a config you have been sent, a source file you are reviewing — and you want to read it the way it was written: keywords in one colour, strings in another, comments out of the way. Not to edit a build, not to set up a project. Just to open the file and see it.
This guide covers what Note My colours, what each colour marks, and how to hand a tab the language you want it read as.
Nothing is downloaded to make this work and there is no account to create. Every language is built in, and it all happens on your Mac — a file you open is never uploaded and never leaves the machine.
Colour on screen, your file exactly as it arrived
This is the fact to settle first, because it governs everything else. Our syntax engine shows colour on screen; it never puts colour into your file. The consequences are worth being precise about:
- Opening a file and reading it never marks the document as changed. The tab title stays exactly as it was, because nothing was edited.
- Saving writes exactly the bytes you had. No colour, no markup, no wrapper.
The same is true of the two other things that add colour over your text: log highlighting and the highlight-every-occurrence behaviour below. All three are shown on screen only; none of them touch a byte of the file. You can open a colleague's file, read it, close it and hand it back exactly as it arrived.
Open the file — it is already coloured
There is no setup step, no project to create, and no per-language switch to find. The work is in the opening.
-
Open the file
Press ⌘O and choose it, or drag it from the Finder onto the tab bar, or — once the Finder extension is switched on in System Settings — right-click it in the Finder and choose Note My ▸ Open. Several files at once is fine; each arrives in its own tab.
If macOS insists the file is not text — no extension, or an extension owned by something else — press ⇧⌘O for File ▸ Open Anything as Text….
-
Check which language the tab is using
Our advanced language identifier sets this as the file opens, so there is nothing to pick first. The tab carries a small language icon, which keeps its own colour even when the tab is selected, so you can read the whole strip at a glance. The status bar carries an Identify pill for the same question.
-
Set the language yourself when you need to
Click the Identify pill. The Language Inspector opens, states "Identified programming language: X", and gives you an override pop-up with Confirm and Cancel. Choose the language you want and the colouring changes as you confirm. Your choice stays with that tab, so nothing will move it back while you read.
The fifteen languages that are fully coloured
Fifteen code languages are fully coloured, and each of them also brings completion keywords, built-in names, and the declarations already written in your own file offered back to you as you type:
| Family | Languages |
|---|---|
| Apple and systems | Swift · C · C++ · Rust · Go |
| Web and scripting | JavaScript · TypeScript · HTML · CSS · PHP · Ruby · Python · Shell |
| JVM | Java · Kotlin |
Two further modes sit alongside them, making seventeen in total: Plain Text, which is the prose mode, and a Custom… entry. Plain Text is also where a familiar set of files lands — .env files, Dockerfile, Makefile, extensionless scripts and every brand-new empty tab. They open, edit and save exactly as they are, and one click on the Identify pill hands any of them the colouring of whichever language you choose — Shell for a script with no extension, say, or Python for a snippet you have just pasted in.
Colour is the start of it. Twelve of the fifteen also bring call tips — Swift, C, C++, Rust, Go, JavaScript, TypeScript, Java, Kotlin, PHP, Ruby and Python — and four of those twelve, Swift, Python, JavaScript and TypeScript, go further again with automatic import lines. Most of the languages carry their own tab icon and accent colour as well, so a long strip of open tabs tells you what is what before you have read a single filename.
What each colour is telling you
Our syntax engine marks seven kinds of thing, each in its own colour. Once you know the seven, a screen of unfamiliar code becomes navigable: you can see where the declarations are and where the work happens.
| Class | What it marks |
|---|---|
| Keywords | The language's reserved words — the control flow and declarations. |
| Types | Type names, both the language's own and the ones you declare. |
| Built-ins | The standard names that come with the language itself. |
| Literals and numbers | Constant words and numeric literals. |
| Strings | Quoted text, with escape sequences painted over the string colour so you can see them. |
| Comments | Line and block comments, in every form the language allows. |
| Function names | Function names, so the shape of a file reads from the colour alone. |
One piece of behaviour is worth knowing because you will notice its effect. An unbalanced quote colours to the end of its line and stops there, so it never runs away and paints the rest of your file as a string — one stray character never costs you the colour on everything below it.
Genuine multi-line strings behave the other way about: Python's """ and ''' blocks, and JavaScript and TypeScript backticks, all keep their colour across every line they cover. Inside a backtick string, ${…} interpolation is coloured as code again, because that is what it is. In JavaScript and TypeScript a regular expression reads as a regular expression rather than as a division sign — the same character, opposite meanings.
The per-language extras
Beyond the shared classes, several languages get colouring for the things that actually carry meaning in them:
- HTML — tags.
- CSS — selectors.
- Ruby — symbols.
- PHP and Shell —
$variables. - Rust — macros.
The rules that colour code in every language
In all fifteen code languages, our syntax engine also picks out names written in the conventions programmers share, whether or not the language itself treats them as special:
- UpperCamelCase names take the type colour.
- SCREAMING_SNAKE_CASE names take the literal colour.
@attributesand#directivesare picked out, as is the C preprocessor.
So a language you do not know well still reads better than plain black text: the types stand out from the values and the constants from the variables. These conventions come with any of the fifteen code languages, so if a file looks flatter than you expect, the Identify pill is the first place to go: set the language you want and the whole page reorganises itself in front of you.
Colour that keeps up while you type and scroll
Colour earns its place by keeping up with you. Our syntax engine paints as quickly as you work, so a coloured source file handles exactly like a plain one under your hands. What to expect:
| What you are doing | What you see |
|---|---|
| Typing in a long source file | Colour lands with the keystroke. No pause, no flicker on the line you are editing. |
| Scrolling, or flinging through a file | Lines arrive already coloured. No trail of grey text behind the scroller. |
| Pasting a large block in | The pasted text is coloured as soon as it lands. |
| Jumping far into a very large file | The window keeps answering you, and colour lands around you as you read. |
None of this asks anything of you. Colour keeps itself current as you work, so it is never something you have to ask for again, and there is nothing to tune to make it behave on a particular file. When you do want a tab plain — reading prose, or looking at a file as characters rather than as code — set its language to Plain Text and the colour steps aside until you choose otherwise.
Very large files deserve a note of their own. Our large-file engine keeps a generated source file or a day of server logs open and readable at sizes where you would expect a stall, and colour stays on throughout. You can scroll a machine-written file from top to bottom, land on the line someone sent you, and read it with the same keywords, strings and comments picked out as in a file of twenty lines.
All of this happens on your Mac. A file you open is not uploaded anywhere to be coloured or read, which is worth knowing when it is a production config or a log full of customer data.
Two things that make code easier to read
Double-click an identifier and the selection snaps to its whole extent, then every other occurrence of it is highlighted. Matching is whole-name, so it will not light up id inside width. It is the fastest way to answer "where else is this used?" in code you did not write.
Double-click a brace and everything between it and its partner folds out of sight; double-click again, click where the folded text was, or click the gutter arrow, and it returns. Pairs are {}, () and []. Folding never alters your text — what you save is identical whether a block is folded or open. It suits reading around one long function: fold it away, follow what happens either side of it, then bring it back with a second double-click.
Between them they answer the two questions an unfamiliar file raises soonest: where else is this name used, and where does this block end. Neither asks you to learn a shortcut, and neither leaves a mark — a double-click does both, and the file is the same afterwards.
Colour built for the shape of a log
A server log gets colouring of its own, built for the shape of a log rather than for a language, and turned on by View ▸ Enable Log Highlighting or by the Log pill in the status bar: a colour per severity level, HTTP status codes as 2xx green, 3xx teal, 4xx orange and 5xx red, ISO-8601 timestamps deliberately muted, IPv4 addresses purple, UUIDs indigo, and URLs in the link colour. Like syntax colour, it is shown on screen and never written into the file.
Reach for it when you are hunting the one line that went wrong: the muted timestamps keep the left margin quiet and the red 5xx codes pull the eye straight to the failures. Turn it off from the same pill.
Taking the colours with you
When the file has to travel — into a ticket, a document, a review someone else will read — the colour travels with it. Three exports keep it, under File ▸ Export As:
| Format | What you get |
|---|---|
| HTML with Syntax Highlighting… | A single self-contained page — one file to send or post, with an optional line-number gutter. |
| RTF with Syntax Highlighting… | Colouring preserved as rich text. |
| PDF… | A fixed page, colours intact. |
Choose by where the file is going: HTML for a page or a ticket, RTF for a document, PDF when it has to look the same for everyone who opens it. No size limit is applied to any of them.
Printing keeps the colours too: ⌘P for File ▸ Print…, ⇧⌘P for Page Setup. Six print options are all on by default — line numbers, a print-friendly light theme, header, footer, wrapped long lines and file metadata. The light theme matters if you work in dark mode: the colours are remapped for paper, so they stay readable on white instead of coming out pale and washed.
Troubleshooting
Giving colour to a file that opened plain
A short fragment, a file saved without an extension, a snippet pasted into a brand-new tab: these arrive in Plain Text, which is the prose mode, and one click puts that right. Click the Identify pill, choose the language from the override pop-up, and the colour appears as you confirm. Save the file with the usual extension and it will open coloured every time after that, with nothing to repeat.
Colouring a stylesheet before it has a name
Save the file with a .css name and it will open coloured from then on. If you are working on it before that — a stylesheet pasted into a new tab, say — click Identify and choose CSS. Colouring starts at once, with selectors picked out alongside the shared classes.
Text has spell-check underlines instead of colour
The tab is in Plain Text mode, which shows macOS's own spelling and grammar underlines in place of syntax colour — including your own "Learn Spelling" entries. Set a code language on the tab to swap back. Note that no mode ever enables a text-mutating assist: no auto-correction, no smart quotes, no dash substitution, no link or data detection, anywhere in the app. Your quotes stay straight and your hyphens stay hyphens.
Reading a very large file at speed
Fling through a generated source file or a day of server logs and the window answers you the whole way down. Our large-file engine holds the colour on while you travel, so you land on the line someone sent you and read it with the keywords, strings and comments picked out exactly as in a file of twenty lines. Colour arrives around you as you read, and it needs nothing from you while it does — keep scrolling, keep searching, and it keeps pace. To pick out every use of a name in a file that size, our find and replace is the instrument that suits it: switch on Whole Word for identifier matching, watch the count run live as you type, and bookmark or step through every hit. The file stays as readable at its far end as it was at the top.
Turning on Copy as HTML and Copy as RTF
One switch under Settings ▸ Print & Export brings both commands into the Edit menu, ready to put coloured code straight on the clipboard: select the lines that matter, choose Copy as HTML or Copy as RTF, and paste them into a document or a ticket with the colouring along for the ride. File ▸ Export As covers the same ground whenever you would rather have a file than a clipboard: the HTML export gives you a single self-contained page, and the RTF export keeps the colouring as rich text you can paste into a document.
One palette, chosen for you
The colours are settled before you arrive, which is the point of them. One theme, tuned twice — once for light appearance and once for dark — so the seven classes stay legible whichever your Mac is using, and a file you read at your desk in the morning is the same file to you at night. Nothing to pick on the way in, nothing to maintain afterwards, and nothing that drifts as you move between machines.
Because the palette comes from the language rather than from a preference somebody set, a file reads the same on every Mac that opens it. Send a colleague the HTML export and they see the file the way you saw it. Colour here describes what the characters are — this is a keyword, that is a string, this stretch is a comment — and that is precisely what makes an unfamiliar file navigable in the first few seconds: you can see the shape of it before you have read a word.
And every text file opens, whatever it is called or not called. A config with no extension, a data file, a log someone has emailed you, a fragment on the clipboard: each one arrives in an editable tab where you can read it, search it, fold a long block out of the way and save it back exactly as it came. Set a code language on the tab whenever you want the colouring that goes with it, and leave it in Plain Text when you would rather read the characters as they are.
Frequently asked questions
Do I have to install anything to get colour for my language?
Open the file and it is coloured. The fifteen languages are built in, with nothing to download, enable or configure, and nothing to set up the first time either. It all happens on your Mac, with no account and no upload.
Does syntax colouring change or reformat my file?
Colour is shown on screen and never enters the document. Opening a file to read it leaves the bytes untouched, and saving writes exactly what you had — so you can open a colleague's file, read it and hand it back as it arrived.
Can I turn colour off for one file?
Yes — set that tab's language to Plain Text from the Identify pill. The colour goes and macOS spell-check underlines take its place. Other tabs are unaffected.
Does colouring slow down typing in a big source file?
Colour lands with the keystroke in a long source file, and it keeps pace when you scroll. There is nothing to switch off to make a big file behave, and no setting to tune. Even in the largest files you are likely to open, our large-file engine keeps the colour on rather than dropping it to cope.
Does a stray quote colour the rest of my file?
A stray quote colours to the end of its line and stops there. Only genuine multi-line constructs — Python triple quotes, JavaScript and TypeScript backticks, block comments — carry colour across lines, so one mistyped character never costs you the colour on everything below it.
Can I get coloured code into a document or a slide?
Export it. File ▸ Export As ▸ HTML with Syntax Highlighting… produces a single self-contained page; the RTF and PDF exports keep the colours too, and RTF is the one to choose if it is going into a document. Printing keeps them as well, remapped for paper by default.