TIL: less lets you toggle startup flags interactively

I love the less pager. You can use it to read, search, tail, and more. As with many versatile programs, however, the man page for less has a bazillion different options:

$ man less

NAME
    less - opposite of more

SYNOPSIS
    less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]

There’s hardly a letter it doesn’t use!

Of these, my favorites are:

  • -S or --chop-long-lines. Truncate lines rather than wrapping them.
  • -N or --LINE-NUMBERS. Show line numbers at the start of each line.
  • -R or --RAW-CONTROL-CHARS. Show control characters vs. interpret them.

You can supply these as flags when starting less. But you often don’t start less directly; it’s set as your pager and then gets invoked when you run commands that produce lots of output, like man or git. No matter because you can type the startup flags while less is running to toggle their behavior!

If lines are wrapped and you want to truncate them, just type -S. You’ll see a message at bottom describing the change and then you press enter to accept. Want to see what line number something is on? Type -N, enter.

Screen recording of opening an HTTP request log with less, then toggling escape codes to color, toggling wrapped long lines to be truncated, then enabling line numbers

As an aside: the dominant pager that preceded less was more. Despite the names, less has more features. On macOS, more is now less (or more precisely, /usr/bin/more and /usr/bin/less are the same file):

ls -lih /usr/bin/more /usr/bin/less
1152921500312523552 -rwxr-xr-x  2 360K Nov 22  2025 /usr/bin/less
1152921500312523552 -rwxr-xr-x  2 360K Nov 22  2025 /usr/bin/more

Whether you get more’s impoverished capabilities or less’s expansive set is determined by the name you use to invoke it.