Less: a Survival Guide

June 2024

I noticed recently that I was having trouble moving around in less. I could arrow up and down, but that took a lot of work. I could hit space to go a whole screen down, but unlike in a web browser, shift-space also scrolls down. How could I scroll up a screen? On some terminals, Page Up and Page Down work, but not in others.

It's a confusing mess.

So, after years and years of using less, I finally looked up how to move around natively. Native less commands will work everywhere! Here's the most useful things I found. As a bonus, I also ran into some ways to configure less to be more helpful!

General less commands


Open a summary of less commands and options.

q or =ZZ

quit less. This isn't exactly navigation, but is pretty important.


These commands move around in the output.

up, down

Move a single line up or down.

left, right

Move a half screen left or right.


Move forward (down) a whole screen.


Move backward (up) a whole screen.


Move down half a screen.


Move up half a screen.

g or <

Go to the beginning of the output.

G or >

Go to the end of the output.

They also work with the control modifier, if for some reason you want to press more keys.

I've been finding that d and u are pretty easy to remember, but a lot of the other ones are more difficult. Some of the commands are taken from vi, so if you already know vi, that helps.


When I'm using less, there's generally a lot of text. Fortunately, less lets you search in the text it's displaying!


Begin a search. Type your query, then press return to jump to the next result.


Go to the next match for the search.


Go to the previous match for the search.


Less is actually configurable! Here are some command line options. If you prefer – perhaps because less has been spawned from another program – they can also be typed once less is running.


Toggle case sensitivity for searching, unless the search query contains capital letters.


Put a marker on the left edge of the screen on every line that the current search matches.


After a forward jump of more than one line, highlight the first new line. Unfortunately, this doesn't work for jumping backwards.


When a line is marked (as with -W), mark the whole line instead.


Start searching as soon as you start typing the search query.


Use color in less's output!


Output incoming escape characters in raw form. This helps when the input contains these control characters, like when running git diff or a similar command.

Enabling options permanently

The settings can be set in an environmental variable LESS.

For example, if you're using bash, you might add this to your ~/.profile:

export LESS="-J -i -W --status-line --incsearch --use-color -R"

Or, for Fish shell, run this command:

set -Ux LESS "-J -i -W --status-line --incsearch --use-color -R"

I set them in my shell, and now everywhere I use less, it works the way I want it to work. More or less.

If you want to hear when I publish more, sign up for my mailing list!


    < An Improved Emacs Search
    tag: til


    < Simple tricks with Imagemagick
    tag: command line