GNU Less Keyboard Shortcuts

A photograph of a laptop running a terminal emulator.

GNU Less is a simple terminal pager program that can print, scroll and highlight text. Mark Nudelman wrote it as a robust free software alternative to the original BSD UNIX “more” program. Nowadays, less is a core part of the GNU toolset, and, as such, it comes with almost all Linux distros by default.

GNU Less Keyboard Shortcuts Download

Download this Cheatsheet

Enter your email below to receive this PDF cheatsheet in your Inbox.

Essential GNU Less Keyboard Shortcuts

One of the biggest strengths of GNU Less is that it is simple and easy to use. Unlike other text pagers and printers, it uses almost no dependencies, and it will work even on the simple console output. You can easily save your terminal output to a file and perform virtually any desired task. Furthermore, GNU Less also comes with keyboard shortcuts that can make browsing text flexible and intuitive.

This cheat sheet will show you how to make the most of GNU Less by highlighting its most common features and keybindings. Not only that, but this cheat sheet will also show some of the pager’s advanced commands along with their shortcuts.

ShortcutFunction
Buffer Movement
JMove the buffer one line down.
KMove the buffer one line up.
FMove the buffer one window down.
BMove the buffer one window up.
DMove the buffer by half a window down.
UMove the buffer by half a window up.
Right ArrowMove the buffer by half a window to the right.
Left ArrowMove the buffer by half a window to the left.
Esc + SpaceMove the buffer one window down while ignoring the file’s EOF signal.
Shift + FGo to the end of the file and wait for incoming data.
Bookmarking and Navigation
M + QCreate a temporary cursor bookmark and save it on the Q register.
Quote (‘) + QGo to the location of the cursor bookmark on the Q register.
Quote (‘) + Quote (‘)Go to the location of the previous cursor bookmark.
GGo to the first line of the file.
Shift + GGo to the last line of the file.
50 + PPlace the cursor in the middle of the file.
Text Searching
Slash (/)Open GNU Less’ search forward prompt.
Shift + Slash (/)Open GNU Less’ search backward prompt.
Slash (/) + Exclamation (!)Perform an inverse forward search.
Shift + Slash (/) + Exclamation (!)Perform an inverse backward search.
NFind the next instance of the current word query.
Shift + NFind the previous instance of the current word query.
Esc + UToggle GNU Less’ query highlighting.
Ampersand (&)Find and print the lines that contain the current word query.
Slash (/) + Asterisk (*)Open the multi-file search forward prompt.
Shift + Slash (/) + Asterisk (*)Open the multi-file search backward prompt.
Esc + NPerform a multi-file forward search for the current word query.
Esc, then Shift + NPerform a multi-file backward search for the current word query.
Slash (/) + Asperand (@)Do a sequential multi-file forward search.
Shift + Slash (/) + Asperand (@)Do a sequential multi-file backward search.
Left Square Bracket ([)Find the matching right square bracket (]) in the current buffer.
Right Square Bracket (])Find the matching left square bracket ([) in the current buffer.
File and Interface Manipulation
HOpen the GNU Less help screen.
Shift + VPrint the version number of the current GNU Less process.
RRefresh the entire screen.
Shift + RRefresh the entire screen without using GNU Less’ buffer memory.
Shift + Semicolon (;), then EOpen a new file in GNU Less.
Equals (=)Print the file name of the currently loaded file.
Shift + Semicolon (;), then NOpen the next loaded file in the current session.
Shift + Semicolon (;), then POpen the previously loaded file in the current session.
Shift + Semicolon (;), then DRemove the currently loaded file in the current session.
Shift + Semicolon (;), then XOpen the first file in the current session.
VEdit the currently loaded file using the default system editor.
Shift + Backslash (\), then Period (.)Pipe the current screen to a shell command.
Shift + Backslash (\), then Caret (^)Pipe the first line of the file to a shell command.
Shift + Backslash (\), then Dollar ($)Pipe the last line of the file to a shell command.
Shift + Semicolon (;), then QExit the current GNU Less session.
Command Buffer
Esc + LMove the cursor one character to the right.
Esc + HMove the cursor one character to the left.
Esc + 0Move the cursor to the beginning of the input buffer.
Esc + Dollar ($)Move the cursor to the end of the input buffer.
Esc + FMove the cursor one word to the right.
Esc + BMove the cursor one word to the left.
Esc + XDelete the character directly underneath the cursor.
Esc + KPrint the previous command on the input buffer.
Esc + JPrint the most recent command on the input buffer.
TabToggle the input buffer’s autocomplete feature.
Esc + TabCycle through the input buffer’s autocomplete hints.
Ctrl + GDelete the contents of the current input buffer.
Ctrl + UCancel the command in the current input buffer.

Image credit: Unsplash. All alterations by Ramces Red.

Ramces Red Avatar

Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Read next

When Cingular chief Stan Sigman backed the original iPhone before its 2007 unveiling, he accepted terms American carriers usually refused: no logo on the device, no control over its software, no preloaded apps, and a share of monthly subscriber revenue flowing back to Apple, after signing on without seeing a prototype
In 2016, archaeologists dated two rings of snapped stalagmites in France’s Bruniquel Cave to 176,500 years ago, evidence that Neanderthals had walked 336 metres into darkness with fire and built architecture deep underground long before modern humans reached Europe
Otto von Bismarck was 74 when Germany adopted the world’s first national old-age social insurance program in 1889, setting the pension age at 70 after years of fighting socialists with bans, laws, and a promise few workers would live long enough to use
When cosmonaut Valeri Polyakov stepped out of his Soyuz capsule in March 1995 after 437 consecutive days aboard Mir, doctors recorded him at several centimetres above his pre-flight height, and his spine had become so unaccustomed to gravity that the recovery team carried him to a chair rather than risk the compression of letting him walk.
When Harvard astronomer Cecilia Payne submitted her 1925 doctoral thesis arguing that the Sun was made almost entirely of hydrogen, the field’s senior figure Henry Norris Russell talked her into adding a line calling the result ‘almost certainly not real,’ and then published the same conclusion himself four years later to widespread acclaim.
When Edme Mariotte stared at marks on a wall in the 1660s, one mark vanished inside a six-degree hole where the optic nerve leaves the eye and the brain has been filling in wallpaper, sky, and faces ever since
When seismic waves from the Chicxulub impact reached what is now North Dakota roughly ten minutes after the asteroid struck, they appear to have triggered a ten-metre standing wave in an inland river that flung fish onto the bank and buried them under glass beads still falling from the sky.
When survivors near Lake Nyos woke on the morning of 22 August 1986, the cattle were dead in the fields, the birds had fallen out of the trees, and 1,746 of their neighbours were lying where they had stood the night before, with no fire, no flood, and no wound to explain it.