- Updated: January 2, 2026
- 6 min read
Mastering the Less Pager: Tips and Tricks for Efficient Navigation
The less command is a powerful terminal pager that lets you view, search, and navigate large text files quickly, and with a handful of hidden shortcuts you can turn it into a full‑featured, productivity‑boosting console tool.
<!– –>
What Is the less Pager?
less is a Unix‑like utility that displays file contents one screenful at a time, allowing forward and backward navigation without loading the entire file into memory. Unlike more, it supports scrolling, searching, and on‑the‑fly filtering, making it the default choice for developers, sysadmins, and anyone who spends time in a terminal.
Because less reads from standard input as well as from files, it fits naturally into pipelines (grep … | less) and can be invoked directly with one or many file arguments (less file1.log file2.conf). This flexibility is the foundation for the productivity tricks covered below.
Essential Tips and Shortcuts
Opening Files and Navigating Between Them
- Open multiple files at once:
less README.md config.yaml *.log - Switch to another file while inside
less: type:e <filename>(e.g.,:e server.conf). - Move forward/backward through the argument list:
:nfor next,:pfor previous, and:xto rewind to the first file. - Remove a file from the list:
:ddeletes the current file from the session.
Jumping to Specific Locations
- Line number:
123Gjumps to line 123. - Percentage offset:
75%lands you three‑quarters of the way through the file. - Search forward/backward:
/patternand?pattern, thenn/Nto repeat. - Negated search: prefix the pattern with
!to find the next line that does not match.
Filtering and Grep‑Like Views
Press & followed by a regular expression to display only matching lines. Add ! to invert the filter (&!ERROR shows everything except lines containing “ERROR”). This is a quick way to skim massive log files without leaving the pager.
Bookmarks for Instant Return
Mark a location with m + a letter (e.g., ma). Jump back with the single‑quote 'a. Bookmarks persist across all opened files, so you can set mo at the “OPTIONS” section of a man page and me at “EXAMPLES”, then flip between them instantly.
Advanced Features
Bracket Matching
If the top line starts with (, [ or {, pressing that character jumps to its matching closing bracket, positioning it at the bottom of the screen. The reverse works for closing brackets on the bottom line. This is handy when reading source code.
Toggling Options On‑the‑Fly
Inside less you can change most boolean flags without restarting:
-S– toggle “chop long lines” (disable line‑wrap).-G– turn search highlighting on/off.-i/-I– smart‑case vs. case‑sensitive search.-R– enable raw ANSI colour escape sequences.-N– show line numbers.
Just type a literal dash followed by the option (e.g., -S) and the pager updates instantly.
Running External Commands
Prefix a shell command with ! to execute it without leaving less. Examples:
!date– prints the current date.!bc– opens a calculator for quick arithmetic.
Environment Variable $LESS
Persist your favourite flag set by defining LESS="-RNe" in ~/.bashrc (or the shell’s profile). This automatically enables colour, line numbers, and exit‑on‑EOF for every less session.
Custom Environment Settings and Tags
While many users never touch less tags, the utility can read ctags files, allowing you to jump to symbol definitions in source code. Set the LESSKEY file to bind custom key sequences, or create a .lesskey entry such as:
#command
e :e
b :b
After running lesskey, these shortcuts become native to your pager.
Editing and Logging Output
When you need to edit the file you’re viewing, press v (or V) to launch the editor defined by $VISUAL or $EDITOR. For data streamed via a pipe, you can write the captured output to a file with o (append) or O (overwrite). This is useful for saving filtered log excerpts without leaving the pager.
Practical Use‑Cases and Real‑World Examples
Log File Analysis
System administrators often need to sift through gigabytes of logs. Combine & filtering with bookmarks to isolate error blocks, then use !date to timestamp findings. Example workflow:
- Open the log:
less /var/log/syslog - Filter for “ERROR”:
&ERROR - Mark the first occurrence:
ma - Search forward for the next error:
/ERRORthenn - When done, write the filtered view:
o errors.txt
Source Code Review
When reviewing C code, open the source and its header together:
less main.c utils.h
Use :e utils.h to jump, m to bookmark function definitions, and bracket matching to locate matching braces quickly.
One‑Liner Documentation Lookup
Developers can pipe man output directly into less with colour support:
MANPAGER="less -R" man git-commit
Toggle line numbers (-N) and search highlighting (-G) on the fly to find option tables faster.
Conclusion & Call‑to‑Action
Mastering less transforms a simple pager into a versatile, script‑friendly console companion. By applying the shortcuts above, you’ll cut down on context switches, speed up log triage, and navigate codebases without leaving the terminal.
Ready to supercharge your workflow even further? Explore the UBOS homepage for an integrated AI‑driven development platform, or dive into the UBOS platform overview to see how AI can automate repetitive command‑line tasks.
Looking for ready‑made templates that embed less usage examples into your internal docs? Check out the UBOS templates for quick start and the AI SEO Analyzer to keep your own documentation SEO‑friendly.
For developers building AI‑enhanced CLI tools, the ChatGPT and Telegram integration and the OpenAI ChatGPT integration showcase how conversational agents can invoke less behind the scenes to present logs to end‑users.
Start applying these tips today, and watch your terminal productivity soar. Need personalized guidance? Join the UBOS partner program or contact our support via the About UBOS page.
Further Reading & Resources
- AI marketing agents – automate content creation and distribution.
- UBOS pricing plans – find a tier that fits your team.
- Workflow automation studio – build no‑code pipelines that include
lessas a step. - Web app editor on UBOS – create web interfaces for your CLI tools.
- Enterprise AI platform by UBOS – scale AI‑driven operations across the organization.
- UBOS for startups – fast‑track your MVP with AI‑enhanced tooling.
- UBOS solutions for SMBs – affordable AI automation for small teams.
- AI Article Copywriter – generate documentation like this guide automatically.
- AI Image Generator – create custom visuals for your terminal tutorials.
- AI Email Marketing – promote your new CLI tricks to a wider audience.
- Video AI Chat Bot – embed interactive help directly into your docs.
Original source of the tips: Assorted less tips article.
Andrii Bidochko
CTO UBOS
Andrii Bidochko is an AI entrepreneur and researcher focused on AI agents, reinforcement learning, and autonomous systems. He writes about the technologies shaping the future of machine intelligence, from frontier models and agent architectures to real-world AI applications.