TL;DR
Tim Chase collected a set of practical tips for the pager less(1) originally shared on Reddit. The notes cover opening and managing multiple files, advanced search and filtering, bookmarks and bracket matching, toggling options inside less, and a few miscellaneous capabilities like editing or dumping stdin to a file.
What happened
In a Reddit discussion, Tim Chase consolidated a range of lesser-known but useful features of the Unix pager less(1). The write-up explains how to start less on multiple files (e.g., less README.txt file.c *.md), add files after startup with :e, move between files with :n and :p, and remove the current file from the argument list with :d. It documents navigation commands such as «count»G for line numbers and «count»% for percentage offsets. Search modifiers (!, *, @, @*) change scope and behavior across matches and files. The notes describe & filtering (and &! for inverse), setting marks with m + letter and returning with 'letter, basic bracket-matching motions, and defining custom match pairs. Chase also covers toggling boolean options from inside less using -<option>, running shell commands via !, using v to edit the current document, and writing stdin to a file with o/O.
Why it matters
- Speeds up file inspection and navigation without leaving the pager.
- Avoids re-running long or expensive commands by changing display options in-place.
- Makes log browsing and multi-file code review more efficient through filtering and marks.
- Leverages built-in features (search modifiers, bracket matching, external edits) to reduce context switching.
Key facts
- Start less on multiple files directly: less README.txt file.c *.md
- Add a file after starting with :e filename and navigate with :n (next), :p (previous) and 😡 (rewind to first).
- Delete the current file from the argument list with :d.
- Jump to a specific line using «count»G (e.g., 3141G) or to a percentage using «count»% (e.g., 75%).
- Search with /pattern and modify behavior with prefixes: ! (invert match), * (across files), @ (rewind to first file), and @* (rewind and search across files).
- Filter displayed lines using &pattern; use &!pattern to show only non-matching lines.
- Set bookmarks with m + letter and return with ' + letter; marks persist across files.
- Typing a bracket character on the screen jumps to its match; custom pairs can be defined with Alt+Ctrl+f/b.
- Toggle boolean less options in-session by typing – followed by the option (examples: -S, -G, -i/-I, -R, -N/-n).
- Run a shell command from less with !cmd; use v to open the current file in $VISUAL; save stdin-collected output to a file with o (append) or O (overwrite).
What to watch next
- Bracket-matching motion can shift the screen in unexpected directions when the pair are less than a screen-height apart, which may feel disorienting.
- Toggling options with – avoids rerunning long commands, but remember these changes affect only the current less session.
- less supports tags generated by ctags, but the author notes he has rarely used that feature.
- not confirmed in the source
Quick glossary
- less: A terminal pager program used to view (but not edit) text files and command output one screen at a time.
- $LESS: An environment variable in which you can place default less options so they apply each time less starts.
- stdin: Standard input stream; many commands send their output to stdout, which can be piped into less.
- marks (bookmarks): Persistent positions set inside less with m + letter and returned to with ' + letter; they work across open files.
- filtering (&): less’s internal pattern filter: &pattern shows only matching lines; &!pattern shows only non-matching lines.
Reader FAQ
How do I open several files at once in less?
Pass multiple filenames on the command line, for example: less README.txt file.c *.md.
Can I add another file after less has started?
Yes — use :e filename to add a file to the argument list during a session.
How can I search across all files starting from the first one?
Prefix the search with @* and then the pattern, for example: /@*pattern.
Is it possible to edit the viewed file from less?
Yes — the v command opens the current document in your $VISUAL editor.
Assorted less(1) tips Tim Chase 2025-11-11 "word to your moms, I came to drop bombs, I've got more less tips than the Bible's got Psalms." In a recent discussion on…
Sources
- Assorted Less(1) Tips
- Adamant – A Perk Overhaul at Skyrim Special Edition Nexus
- Magical Hack – No More Secrets
- Unix Less Command: 10 Tips for Effective Navigation
Related posts
- A small collection of text-only websites: plain-text browsing list
- How One Google Calendar Feature Can Help You Reclaim Your Workday
- FracturedJson: a compact, human-friendly JSON formatter for developers