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.

Is this post useful?
Subscribe to our newsletter!

Our latest tutorials delivered straight to your inbox

Ramces Red
Ramces Red - Staff Writer

Ramces is a technology writer that lived with computers all his life. A prolific reader and a student of Anthropology, he is an eccentric character that writes articles about Linux and anything *nix.