How to change the syntax language of a file on Mac
Note My lets you set the language on any file, so a shell script with no extension is not stuck as flat black text. Here is where that control lives, what it changes on screen, and why your file on disk is left untouched by it.
A file opens and the colours are wrong. A shell script with no extension arrives as flat black text. Or you have just pressed ⌘N and the new, empty document opens as Plain Text. In each case you want the same thing: a control that says "this file is Python", and colouring that follows.
That control exists in Note My. It is called the Language Inspector, and the way in is the Identify pill in the status bar.
Which files arrive already coloured
Most documents need nothing from you. Our advanced language identifier gives the common ones their colours the moment they open, so a Swift file, a Python script, a stylesheet or a familiar build file — CMakeLists.txt, Dockerfile, Makefile — is ready to read straight away. It all happens on your Mac: nothing is uploaded, there is no account, and the file never leaves the machine. This guide is about the ones left over.
Three situations cover almost everything, in rough order of how often they come up.
- The file arrives already coloured. There is nothing to do. The current language is always shown in the status bar, so a glance confirms it before you start editing.
- The file arrives as flat text — a deployment script called
deploy, a dotfile, a snippet a colleague sent you. Open the Language Inspector and set the language yourself; it takes a couple of seconds, and the tab keeps that choice. - The document is brand new. An untitled document opens as Plain Text. Set a language from the Inspector, or paste your code in and let Note My set it for you.
Plain Text is a mode with a job of its own. It is what a brand-new untitled document, an extensionless script and a .env file open in, and it is the mode you want for anything where a stray substitution would break the file.
Change the language of an open file
-
Find the Identify pill
Look along the status bar, past the six counters — Chars, Words, Spaces, Lines, Sel and Occ. You will see the document's current language, and next to it a pill labelled Identify. That is the entry point, one click away wherever you are in the document and in view the whole time you work.
-
Open the Language Inspector
Click Identify. A small card sheet drops from the title bar, compact and translucent, so it reads as part of the window rather than as an interruption.
-
Read what it says
On a document with content the card reads "Identified programming language: X", where X is the language the document is using now. On an empty document it reads the neutral "Set programming language" instead. Either way, the choice underneath is yours to change.
-
Override it from the pop-up
Below the sentence is a pop-up menu of the fifteen code languages — Swift, Python, JavaScript, TypeScript, Java, C, C++, Ruby, HTML, CSS, PHP, Rust, Go, Kotlin and Shell — plus Plain Text, for prose and for any file a stray substitution would break. Pick the one you want and the whole document follows it.
-
Confirm
Press Confirm to apply it, or Cancel to leave the document as it was. Applying a language changes what you see and nothing else. Colour never reaches the file, so not one byte changes and you are left with nothing new to save.
Once you have made a choice for a tab, Note My never overrides it. A language you set by hand is never quietly swapped for another behind your back, however much you type, paste or scroll afterwards. If you change your mind, click Identify again and pick something else.
Setting the language on a brand-new file
A new, untitled document opens as Plain Text. There are two ways to give it a language, and both take seconds.
Open the Inspector and choose one. The card reads "Set programming language" and behaves exactly as above.
Or paste. Paste code into a brand-new empty tab and the language is set for you, once, quietly, with no sheet and no confirmation. Pasting is the only thing that does this — nothing you type and nothing you scroll past ever changes a language on you. A tab that is still Plain Text stays open to the next paste you make into it, and the Language Inspector is always one click away if you would rather make the call yourself from the outset.
In a tab that already has a language, your choice stands and the paste simply offers. It puts an accent dot on the Identify pill to say a suggestion is waiting, together with a short explanatory popover the first time it happens. The dot is an offer and nothing more: it applies nothing on its own, it does not interrupt what you are typing, and it clears once you open the Inspector and make a choice. Ignore it and the tab carries on in the language it already had.
What the choice actually changes
| Area | Effect of the language choice |
|---|---|
| Highlighting | Our syntax engine colours the document for that language: keywords, types, built-ins, numbers, strings, comments, function names, plus per-language extras such as HTML tags, CSS selectors, Ruby symbols and Rust macros. |
| Completion | Keyword and built-in suggestions match the language you chose. |
| Call tips | Signatures appear as you type in Swift, Python, JavaScript, TypeScript, Java, C, C++, Ruby, PHP, Rust, Go and Kotlin, so the arguments a call expects are in front of you. |
| Auto-import lines | In Swift, Python, JavaScript and TypeScript, a suggestion can bring the import line a symbol needs along with the symbol. |
| Re-indentation | Our indentation engine tidies the document to that language's conventions. The Indentation sheet also carries its own picker of the global default plus the fifteen languages. |
| Text cleanup | Our cleanup rules change what counts as a serious problem — in Python, mixed indentation is raised to danger; in shell, CRLF line endings are. |
| The file itself | Nothing. No bytes change. |
Two things follow from that table. The language is worth setting even on a file you are only reading, because the suggestions, the call tips and the cleanup warnings all sharpen once it is right. And nothing in the list touches your content, so there is no risk in trying one to see how the file looks. With a mixed file, pick the language you are editing rather than the one the file is named after.
Switching a tab to Plain Text for prose
Plain Text is a mode in its own right, with behaviour of its own. Choosing it swaps the code colouring for macOS's own spell-check and grammar underlines, so your own added spellings apply the way they do everywhere else on the Mac. It is the right mode for a set of notes, a commit message you are drafting, or a README you want to read as prose.
No mode, prose included, ever rewrites your text. Automatic spelling correction, smart quotes, dash substitution, text replacement, link detection and data detection are off everywhere in the app, in every mode. The underlines are advice; nothing is substituted.
That is deliberate, and it matters most for the files that open in Plain Text anyway — .env files, Dockerfile, Makefile and extensionless scripts. A curly quote in any of those would break the file outright, so no mode anywhere in the app is allowed to introduce one.
Keeping the language after you save
When you save an untitled document, the save panel pre-fills an extension to match the language you chose. Accept it and the file comes back coloured next time you open it, rather than in a mode you have to set again — worth doing for anything you expect to return to.
The suggestion is only a suggestion; type any name you like and the tab keeps the language you set.
Troubleshooting
My file keeps opening as Plain Text
Some files simply arrive that way — an extensionless script, a dotfile, a snippet you saved out of a chat window. Set the language from the Inspector and the choice sticks for that tab. If it is a file you return to often, the tidier fix is to rename it with the extension for its language, so it comes back coloured every time without a second thought.
My stylesheet opens without colour
Give the file the .css extension and it opens coloured every time. If it has to keep another name — a partial, a template fragment, a stylesheet built by something else — open the Language Inspector and choose CSS by hand. Selectors, properties, values and comments separate out immediately, and the tab stays in CSS while you work.
A template with PHP in it opens as PHP, not HTML
That is deliberate. A page that mixes PHP with markup opens as PHP, which is the colouring that covers the parts you are most likely to be editing. If you want the markup colouring instead, override to HTML from the Inspector.
I picked the wrong language
Click Identify again and choose another one. There is nothing to undo first: because a language choice never reaches the text, you can move between modes as often as you like and the file on disk stays exactly as it was. Try two or three on an unfamiliar file and keep whichever reads best.
I want spelling underlines while I write prose
Set that tab to Plain Text from the Language Inspector. The macOS spell and grammar underlines come on for the document, drawing on the same personal dictionary you have taught everywhere else on the Mac. The underlines are advice only — nothing in your text is substituted — and every other tab carries on in the language it was already using.
The Identify pill has a coloured dot on it
You pasted into a tab that already had a language. The dot means a suggestion is waiting; nothing has been applied, and nothing will be unless you ask for it. Click the pill to see it, or ignore it.
Setting the language in a very large file
Choose the language exactly as you would in any other document — the Identify pill and the Inspector behave the same way at any size. Our large-file engine keeps the window responsive throughout, so you can carry on typing and scrolling from the moment you press Confirm, and the text takes on its colours around you as you go. A log file, a database dump or an exported dataset stays a document you can move around in. The work is done on your Mac; nothing is uploaded, whatever the size of the file.
Getting more from the language you set
The language is a property of the document rather than of the app, and that is what makes it comfortable to work with. A Python script, a stylesheet and a set of meeting notes can sit in three tabs at once, each in its own mode; setting one tab to Python leaves every other tab exactly as it was, and moving between them moves the colouring with you. Every choice you make here is local to the tab you make it in, so a language you set stays set and everything else stays where you had it.
A few habits make that one choice do considerably more work for you.
- Give a file the extension for its language. A file named for what it is opens coloured every time, with no trip to the Inspector at all. For an untitled document the save panel offers the right extension already, so accepting it is the whole job.
- Start from a template. Our template library opens a new document with the shape of the work already in place — an SQL query, a Markdown README — so you begin with structure rather than an empty page, and the tab is ready to write in straight away.
- Use Plain Text for the files that read as prose. A README, a changelog, a set of notes: the spelling and grammar underlines come on, and our cleanup rules know to leave trailing whitespace in Markdown alone, since a line break there is deliberate.
- Set the language even on a file you are only reading. Completion, call tips and the cleanup warnings all sharpen once it is right, and none of them touch a byte of your text, so there is nothing to weigh up before trying one.
- Pick the language you are editing, not the one on the label. In a file that mixes two — markup with a scripting language threaded through it — choose the one your hands are actually in, and switch when your attention moves.
- Glance at the pill when something looks unfamiliar. The status bar names the current language at all times, so the answer to "why does this look wrong" is usually one look away, and the fix is one click further.
Frequently asked questions
Does changing the language modify the file?
Your file is left exactly as it was. The colouring is something you see on screen; it never reaches the text itself, so it cannot follow the file into an export, a copy or a paste elsewhere. No bytes change, so a language choice leaves nothing new to save.
How many languages are there?
Fifteen code languages — Swift, Python, JavaScript, TypeScript, Java, C, C++, Ruby, HTML, CSS, PHP, Rust, Go, Kotlin and Shell — plus Plain Text, the mode for prose and for any file a stray substitution would break. They are all in the Language Inspector's pop-up, and any tab can be moved to any of them at any time.
Will Note My override my choice later?
A language you set by hand stays set for that tab. At most you will see a dot on the Identify pill offering a suggestion after a paste, and that suggestion is never applied unless you ask for it.
Why does the same file sometimes look different from what I expected?
Check the language shown in the status bar — it may not be the one you assumed, particularly for a file you opened from somewhere else. Set it from the Inspector and the document takes that language straight away and keeps it while you work.
Can I turn highlighting off for one file only?
Yes. Set that tab to Plain Text. The code colouring stops for that document and the macOS spell and grammar underlines come on instead. Other tabs are unaffected.
How can I be sure which language a tab is using?
The status bar names it in full, next to the Identify pill, so a glance settles it before you start editing. Tab icons and their accent colours are the quick cue from across the window; the pill is the definitive answer, and clicking it opens the Language Inspector if you want to change the mode there and then.