Skip to main content
Glow automatically wraps markdown content to ensure optimal readability in your terminal.

The —width Flag

Set a custom text width with the --width (or -w) flag:
glow README.md --width 100
glow document.md -w 60

Disabling Word Wrap

Set width to 0 to disable word wrapping:
glow README.md --width 0
Disabling word wrap may cause text to overflow your terminal width, requiring horizontal scrolling.

Automatic Terminal Width Detection

When you don’t specify a width, Glow automatically detects your terminal dimensions:
// Detect terminal width
if !cmd.Flags().Changed("width") {
    if isTerminal && width == 0 {
        w, _, err := term.GetSize(int(os.Stdout.Fd()))
        if err == nil {
            width = uint(w)
        }

        if width > 120 {
            width = 120
        }
    }
    if width == 0 {
        width = 80
    }
}
The detection logic (main.go:193-207):
  1. Terminal Detection: Checks if stdout is a terminal
  2. Width Retrieval: Gets the actual terminal width
  3. Maximum Cap: Limits width to 120 columns for readability
  4. Fallback: Defaults to 80 columns if detection fails

Default Width Behavior

1

Terminal Width Detected

If running in a terminal, Glow reads the actual terminal width
2

Apply Maximum (120 columns)

If terminal width exceeds 120 columns, it’s capped at 120 for optimal readability
3

Fallback (80 columns)

If width cannot be detected or is 0, defaults to 80 columns

Why Cap at 120 Columns?

Wide terminals can make text harder to read. Research shows optimal line length for readability is 60-100 characters. The 120-column cap ensures:
  • Comfortable reading experience
  • Prevents excessive eye movement
  • Maintains text structure

Width in Glamour Rendering

The width is passed to Glamour’s rendering engine:
// initialize glamour
r, err := glamour.NewTermRenderer(
    glamour.WithColorProfile(lipgloss.ColorProfile()),
    utils.GlamourStyle(style, isCode),
    glamour.WithWordWrap(int(width)),
    glamour.WithBaseURL(baseURL),
    glamour.WithPreservedNewLines(),
)
This controls how markdown elements wrap:
  • Paragraphs
  • Code blocks
  • Lists
  • Tables
  • Block quotes

Width with Different Output Modes

Standard Output

# Renders at detected terminal width (max 120)
glow README.md

# Custom width
glow README.md --width 80

Pager Mode

Width is applied before piping to the pager:
# Content wrapped at 100 columns, then paged
glow README.md --width 100 --pager

File Redirection

When redirecting output, specify width explicitly:
# Use default 80 columns for redirected output
glow README.md > output.txt

# Specify custom width
glow README.md --width 100 > output.txt

Configuration File

Set a default width in your configuration file (~/.config/glow/glow.yml):
width: 100
The --width flag overrides the configuration file setting.

Examples

Narrow Width for Side-by-Side Viewing

# Good for split terminal panes
glow README.md --width 60

Wide Width for Detailed Content

# Use full 120 columns for technical docs
glow documentation.md --width 120

Responsive to Terminal Resize

# Automatically adjusts to current terminal size (up to 120)
glow README.md

No Wrapping for Code-Heavy Content

# Disable wrapping for files with wide code blocks
glow code-examples.md --width 0

Width and Paging Interaction

The width setting affects how content is formatted before it reaches the pager:
# Content wrapped at 80 columns, then sent to less
export PAGER="less -r"
glow README.md --width 80 --pager
# Width auto-detected, content rendered directly
glow README.md --width 100
For the most comfortable reading experience, let Glow auto-detect your terminal width. It will intelligently cap at 120 columns even on ultra-wide displays.

Build docs developers (and LLMs) love