Formatting & Indentation

How to change tab size and indent width on Mac

You can do this with Note My — here is where the indent width and the tabs-or-spaces choice live, what each of them changes, and how to make a project's house style stick.

A project has a house style: two spaces, or four, or hard tabs. You open a file, type a line, and get something else. Then you paste in a block from somewhere and the file has both. The fix is a single sheet, one click from the document you are already editing, holding every part of the answer: the width, the character, and a per-language rule for the projects that want something of their own.

This guide covers where the indent width and the tabs-or-spaces choice live in Note My, how per-language overrides work, and how typing and re-indenting each follow a rule of their own so you always know which result you are getting.

What "tab size" means here

Two separate things get called tab size, and it is worth splitting them before you go hunting for a control.

The indentation unit is what gets written into the file when a level of indentation is created — four spaces, two spaces, or one tab character. That is the setting this guide is about, and it has two parts: a width, and a choice of whether that width is written as spaces or as a tab.

The depth you read on screen is that same width, which is what makes the setting easy to reason about: one number governs what Return gives you, what a re-indent writes and how deep a level looks, so there is a single value to agree with your project rather than two to keep in step. If a file already contains hard tabs, changing the width leaves them exactly as they are until you re-indent the document, and re-indenting is the step that rewrites them.

Note

The defaults are an indent width of 4, written as spaces. If that is what your project uses, there is nothing to change.

Where the setting lives

The indentation settings have a sheet of their own, and it opens straight from the document you are editing. That is deliberate: indentation is something you judge with the file in front of you, so the control sits where the work is rather than several panes deep in a separate window.

Look for the Indent button in the toolbar, the one drawn as a pair of curly braces. It sits in the same position in every window, so you find it once and never hunt for it again — click it from whichever file you happen to have open.

Clicking it opens the Indentation sheet: a floating panel with a language picker, a brace-style switch, a live preview card, the indent controls, a comment-recovery toggle, a language-specific section, and a footer.

Important

The Indent button opens the sheet and hands you the controls; nothing in your document changes until you press Apply. Closing the sheet with ⎋ leaves the document exactly as it was, so it is safe to open on work you care about and look around.

Set the width and pick tabs or spaces

  1. Open the Indentation sheet

    Click Indent in the toolbar. The sheet opens over the window, already pointed at the language our advanced language identifier has chosen for the document in front of you.

  2. Choose which language you are setting

    The picker at the top offers sixteen options: a global default plus fifteen languages. Pick the global default to change what applies everywhere else, or pick a language to set a rule that applies only to files of that kind.

    Changing the picker moves the brace style, width and tabs-or-spaces controls to that language's current values, so you are always looking at the settings that will actually be used.

  3. Set the width

    The indent width accepts anything from 1 to 12. Four is the default. Two is common in JavaScript and CSS work; eight is there for the projects that ask for it.

  4. Choose tabs or spaces

    Spaces is the default. Switching to tabs means one level of indentation is written as a single tab character rather than as width spaces. The width still matters after that switch: it is what one level of depth is worth, so set both to match your project.

  5. Read the preview, then apply

    The card in the middle of the sheet redraws as you change the controls, so you can weigh two-space against four-space before committing to either. It shows a compact if statement — a style sample, picked so that the width, the character and the brace style are all legible in a few lines.

    Press Apply to save the settings and re-indent the document, or Cancel to save nothing.

Per-language settings, and what Reset to global really resets

A "Reset to global" link appears in the sheet only when the selected language has overrides of its own, and it is more selective than it sounds. Only three things are genuinely held per language: the brace style, the indent width, and the tabs-or-spaces choice. Those are the three it clears. Every other indentation policy — trailing commas, semicolon handling, pointer spacing, continuation style, and roughly two dozen more — belongs to its own language and survives the reset untouched.

Which indentation settings are per-language and which are not
SettingScopeCleared by Reset to global
Indent widthPer language, otherwise globalYes
Tabs or spacesPer language, otherwise globalYes
Brace stylePer language, otherwise globalYes
Every other language policyBelongs to that language onlyNo

The two language locks

Two languages come with a lock of their own rather than a default you have to go and find.

  • Go is locked to tabs, and the lock is on by default. Re-indent a Go file and you get tab characters, whatever the global setting says, unless you turn the lock off.
  • Python is locked to four spaces, and the lock is off by default. Turn it on if you want Python files re-indented to four spaces regardless of the width you have set elsewhere.

Both locks live in the language-specific section of the sheet, and both take effect when you press Apply. That pairs with one more detail worth having: what happens as you type.

How typing and re-indenting each behave

Typing and re-indenting each follow a rule of their own, and knowing which is which puts you in charge of the result. When you press ↩, your current indentation carries onto the next line, and a line that ends in {, [, ( or : adds one more level on top. That extra level uses the global width and the global tabs-or-spaces choice. The Go and Python locks are the business of the Apply button, which is where a whole file is brought into line at once.

So you have two moments of control, and both of them are yours to set. As you type, new lines follow the global width and character, which is what makes a fresh file grow exactly the way you have set the app up. When you press Apply, the document is brought into line with the rule for its language, locks included — that is how a Go file becomes tabs from the first line to the last. Set the global character to tabs as well and the two agree from the first keystroke; leave it as it is and a single Apply before you save does the same job in one step.

Note

While you are typing, a trailing colon adds an indent level in every language, not only in Python. You will get one after a Swift case x: and after a YAML key too.

Seeing which one you actually have

Whitespace is invisible by definition, so the fastest way to settle an argument about a file is to draw it. Turn on Show Invisibles in the toolbar: a space draws as · and a tab as →, and mixed indentation becomes obvious at a glance. Three marker styles are available in Settings ▸ Invisibles — Symbols (the default), Code Points, and Bytes, which shows the hex bytes in the document's own encoding. None of it is written into the file: the markers are only shown on screen, so the file you save is unchanged.

Indentation guides help with depth rather than character. They are on by default, with ten styles in Settings ▸ Guides and Dots as the default. One detail is worth knowing before you read too much into them: the guides are drawn to match the indentation already in the file, not the width you have set. A file written at two shows guides at two even when your setting says four. That is useful: it is a quick way to see a file's real house style.

For a verdict rather than a picture, our cleanup rules flag Mixed tab/space indent as a category of its own, so you get a plain list of the lines where the two are combined. It is informational: the lines are reported, not changed, and you decide what to do about them. In a Python file the finding is raised to the danger level, where a mixed indent can change what the code means; in a Makefile it is not raised at all, because there a tab is part of the syntax. All of it happens on your Mac — nothing is uploaded, there is no account, and the file never leaves the machine.

Matching an existing project

Open a representative file and turn on Show Invisibles: dots mean spaces, arrows mean tabs, and counting the dots on a first-level indent gives you the width. Then open the Indentation sheet, select the language rather than the global default, set the width and the character to match, and press Apply. The three per-language values persist, so you set them once and every later file of that kind follows.

Pick a file a colleague wrote rather than one you have already edited, or you may be measuring your own settings back at yourself. Check a deeply nested line as well as a top-level one: a file can be tidy at the first level and mixed further in.

Troubleshooting

I changed the width but nothing in my file moved

Changing the setting does not reformat anything on its own — the Apply button does. If you changed the width and then pressed Cancel, neither the setting nor the document changed. Reopen the sheet, set the width, and press Apply.

Seeing the new width on your own text

Press Apply. The document is re-indented there and then, so you judge the setting in your own code, at your own nesting depth, with the file in front of you. If you would rather weigh two options before that, the card in the sheet puts the width, the character and the brace style side by side on a short if statement — enough to tell two-space from four-space at a glance. Cancel saves nothing, so you can open the sheet, try both, and decide later.

Reset to global kept my other language settings

By design, and usually what you want. It clears the three values a language holds of its own — brace style, width, and tabs or spaces — and leaves that language's other policies exactly as you tuned them. Adjust any of those individually in the language section of the sheet.

Re-indenting a very large file

Our large-file engine keeps very big documents open and editable — a database dump, a day of server logs — and a whole-document re-indent is a single command that covers the file end to end. On a document of that size the window works for a few seconds before the re-indented text appears; that is the entire file being brought into line in one step, so every line lands together, consistently, from the first to the last.

The result came out at the wrong depth

Check your braces first. If the file has an opening brace with no closing partner, our indentation engine still gives you a result, and that result can sit deeper than you meant from that point on. Fix the brace, apply again, and the depth settles. On a file that matters, save before you press Apply with ⌘S: a saved copy on disk is a known-good reference you can always come back to, and it costs one keystroke. Our auto-recovery safety net holds your work if the app ever closes unexpectedly.

The language is wrong, so the rules are wrong

Our advanced language identifier picks the language for you, and the sheet's picker lets you override that choice before you apply. If the choice is repeatedly wrong for a file, the status-bar Identify pill opens the language inspector, where you can set the language for the document itself.

Settings that stay put

Indentation is one of those preferences worth setting once and then forgetting about. A few things about the way the sheet holds its values make that possible.

  • The three per-language values persist. Set a width and a character for Python once and every Python file you open afterwards follows it — in this window and the next one, today and in six months. The same is true of each of the fifteen languages in the picker, so a machine you work on daily gradually settles into exactly the habits you want.
  • Your settings belong to you, not to the file. Open a colleague's file and your own preferences are still yours; hand yours to them and theirs are still theirs. A house style is something the two of you choose to match, in the sheet, and either of you can bring a file into line with a single Apply.
  • Re-indentation happens when you ask for it. Not on save, not on paste, not on open — only when you press Apply. A file you have not deliberately re-indented is a file that has not been rewritten, which makes the sheet safe to open and experiment with on work you care about.
  • One sheet holds the whole answer. Width, tabs or spaces, brace style, the two language locks and the language-specific policies all sit in the same panel, so when a project changes its mind there is a single place to go and a single Apply to press.
  • You can write the style down for everyone else. Our template library gives you an .editorconfig to start the project from, so the agreed width and character are written down where the rest of the toolchain will read them; set the same two values in the Indentation sheet and your own files match what that file describes.

Frequently asked questions

What is the default indent width?

Four, written as spaces. The sheet accepts any width from 1 to 12.

Where do I find the tab size setting?

In the Indentation sheet, opened by the Indent button in the toolbar — the one drawn as a pair of curly braces. It is one click from whichever document you have open, and it holds the width, the tabs-or-spaces choice and the brace style together, globally or per language.

Can I use tabs in one language and spaces in another?

Yes. The width, the tabs-or-spaces choice and the brace style are all held per language, and where a language has no setting of its own the global default applies. Select the language in the sheet's picker before you change them.

How do I get tabs throughout a Go file?

Two routes, and either one gets you there. Set the global tabs-or-spaces choice to tabs and every level you type is a tab from the first keystroke. Or leave the global choice alone and press Apply: the Go lock takes the whole file to tabs in one step, whenever it suits you. Typing follows the global setting, Apply follows the language lock, so you can have tabs the moment you want them.

Does changing the width alter tabs already in the file?

Your file changes when you ask it to, and not a moment before. Existing characters stay exactly as they are until you re-indent the document, which is the step that rewrites the leading whitespace throughout. Change the width, carry on working, and re-indent when it suits you.

How do I tell whether a line is indented with tabs or spaces?

Turn on Show Invisibles from the toolbar. Spaces draw as a middle dot and tabs as an arrow. For a byte-level answer, switch the marker style to Bytes in Settings ▸ Invisibles.