Nano's Justify Feature: When Two-Sided Text Alignment Helps (and When It Wrecks Your File)
GNU nano's Justify feature re-wraps prose paragraphs to a consistent width in one keystroke. Here's how it decides what a paragraph is, how to try it safely, and why it will destroy your tables if you're careless.
10 Feb 2026, 05:55 UTC

If you write README files, changelogs, or plain-text documentation in a terminal, you've probably hit this: a paragraph of jagged lines, some 40 characters wide, some 75, because you edited sentences in place. Word processors fix this automatically. GNU nano has a lesser-known answer — the Justify feature — and it's genuinely useful, provided you understand what it actually does to your buffer before you press the key.
The short version: Justify re-wraps a paragraph so it fills the available width, aligning text against both the left and right edges. It's a formatting utility for prose, not a layout engine. Used on the right text, it turns ragged paragraphs into tidy blocks in one keystroke. Used on the wrong text, it mangles tables, lists, and indented content beyond easy repair.
What Justify actually does
Nano operates on plain text buffers — there is no hidden markup, no style layer. When you justify, nano recalculates line breaks for the current paragraph and redistributes words so lines reach toward the right margin. A "paragraph" here means a block of text delimited by blank lines. That definition matters: nano can't tell a table from a sentence. Anything between two empty lines is fair game.
The target width comes from nano's wrapping configuration. If you've set a hard wrap column (for example with set fill 72 in your ~/.nanorc, or nano -r 72 file.txt on the command line), justification aims for that column. Otherwise it works against the terminal width, which means the result can change if you resize your window and re-justify.
Trying it safely
Key bindings vary between nano versions and distribution builds, so confirm yours before relying on muscle memory. Inside nano, press Ctrl+G to open the help text and search for "Justify" — in many builds the paragraph justify command is bound to Ctrl+J, and justifying the entire file is available from the justify menu. Your installed man nanorc and man nano pages are the authoritative reference for your build.
A concrete exercise:
- Create a scratch file:
nano /tmp/justify-test.txt(no special permissions needed; use a throwaway path so nothing real is at risk). - Paste a paragraph with deliberately uneven line lengths — three or four lines between 30 and 70 characters works well.
- Place the cursor anywhere in the paragraph and press
Ctrl+J(or the binding your help screen shows). - Observe: the lines should re-flow to a consistent width. Now add a second paragraph below a blank line and justify again — only the paragraph containing the cursor should change.
Undo with Alt+U if the result isn't what you wanted. Nano's undo stack covers justify operations in current versions, but verifying that on your build takes ten seconds and is worth it before you justify a file you care about.
Where it earns its place
Justify shines for prose-heavy plain text: long commit-message bodies you're drafting offline, NEWS or CHANGELOG entries, email drafts composed in a terminal, or documentation meant to be read as raw text. If you maintain files under a style rule like "wrap at 72 columns," justify is the fast way to bring an edited paragraph back into compliance after you've inserted or deleted sentences mid-paragraph.
It pairs naturally with nano's hard-wrap setting. A minimal ~/.nanorc snippet for this workflow:
set fill 72
set breaklongwordsThe fill value sets the justification target; breaklongwords controls whether words longer than a line get split. Check man nanorc for exact option names on your version — older builds have renamed some of these.
The trade-off: justification is destructive to structure
This is the limitation that bites people. Because nano treats any blank-line-delimited block as a paragraph, justify will happily collapse:
- Manually aligned tables or columnar data — your careful spacing becomes word-wrapped mush.
- Indented content such as code snippets or nested lists pasted into a text file.
- Short lines, where justification can insert wide, ugly gaps between words (the "rivers of white space" effect typographers warn about).
There is also no selection-scope justify in many builds: it's the current paragraph or the whole file. If your file mixes prose and structured content, justify paragraph-by-paragraph with the cursor placed deliberately, never the whole file. And because behavior differs across versions and distro builds, test on a copy first if the file matters: cp notes.txt notes.txt.bak before experimenting.
A practical check after justifying anything non-trivial: run git diff (if the file is tracked) or diff notes.txt.bak notes.txt and scan for changes outside the paragraph you intended. If the diff shows reflowed tables or lists, undo and re-justify more selectively.
The takeaway
Justify is a one-trick tool, but the trick is useful: it re-flows prose paragraphs to a consistent width in a single keystroke, using blank lines as paragraph boundaries and your fill setting (or terminal width) as the target. Confirm the binding in Ctrl+G on your build, set an explicit wrap column in ~/.nanorc, and keep it away from tables, code, and lists. For prose in the terminal, it's the fastest path from ragged edits back to clean, readable text.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.