# info > LESS

---
type: CommandReference
command: less
mode: man
section: 1
source: man-pages
---

## Quick Reference

- `less file` — view file
- `less -N file` — show line numbers
- `less -S file` — chop long lines (no wrap)
- `less +F file` — tail -f mode
- `less -p pattern file` — start at first match of pattern
- `less -R file` — display raw ANSI color escapes
- `less -X file` — avoid clearing screen on exit
- `less -?` — display help

## Name

**less** — opposite of more

## Synopsis

less -?
less --help
less -V
less --version
less [-[+]aABcCdeEfFgGiIJKLmMnNqQrRsSuUVwWX~]
     [-b space] [-h lines] [-j line] [-k keyfile]
     [-{oO} logfile] [-p pattern] [-P prompt] [-t tag]
     [-T tagsfile] [-x tab,...] [-y lines] [-[z] lines]
     [-# shift] [+[+]cmd] [--] [filename]...
## Options

### General

- `-?`, `--help` — display command summary
- `-V`, `--version` — show version number
- `-f`, `--force` — open non-regular files (directories, devices)
- `-L`, `--no-lessopen` — ignore LESSOPEN environment variable
- `--file-size` — determine file size immediately on open
- `--follow-name` — follow file by name in F command (reopen on rename)
- `--incsearch` — incremental search (advance as pattern typed)
- `--mouse` — enable mouse wheel scrolling and click to set mark
- `--MOUSE` — reverse mouse wheel direction
- `--no-keypad` — disable keypad initialization strings
- `--no-histdups` — deduplicate history entries
- `--rscroll` — character to mark truncated lines (default: standout)
- `--save-marks` — persist marks across invocations
- `--status-col-width` — width of status column (default 2)
- `--use-backslash` — allow backslash escaping in option strings
- `--use-color` — enable colored text (requires -D)
- `--wheel-lines=n` — lines to scroll per mouse wheel tick (default 1)

### Display

- `-c`, `--clear-screen` — repaint from top line down
- `-C`, `--CLEAR-SCREEN` — same as -c
- `-g`, `--hilite-search` — highlight only current match (not all)
- `-G`, `--HILITE-SEARCH` — suppress all search highlighting
- `-i`, `--ignore-case` — case-insensitive search (unless pattern has uppercase)
- `-I`, `--IGNORE-CASE` — case-insensitive even with uppercase in pattern
- `-j n`, `--jump-target=n` — position target line at screen line n (1‑based, or fraction)
- `-J`, `--status-column` — show status column (search matches, marks)
- `-m`, `--long-prompt` — verbose prompt (like more)
- `-M`, `--LONG-PROMPT` — even more verbose prompt
- `-n`, `--line-numbers` — suppress line numbers (faster for large files)
- `-N`, `--LINE-NUMBERS` — display line numbers at start of each line
- `-r`, `--raw-control-chars` — display raw control characters (not recommended)
- `-R`, `--RAW-CONTROL-CHARS` — display ANSI color escapes and OSC 8 hyperlinks
- `-s`, `--squeeze-blank-lines` — collapse consecutive blank lines into one
- `-S`, `--chop-long-lines` — truncate long lines (no wrap)
- `-u`, `--underline-special` — treat backspaces/carriage returns as printable
- `-U`, `--UNDERLINE-SPECIAL` — treat backspaces/tabs/carriage returns/Unicode formatting as control chars
- `-w`, `--hilite-unread` — highlight first new line after forward page movement
- `-W`, `--HILITE-UNREAD` — highlight first new line after any forward movement >1 line
- `-x n,...`, `--tabs=n,...` — set tab stops (default 8)
- `-X`, `--no-init` — disable termcap init/deinit strings
- `-y n`, `--max-forw-scroll=n` — max lines to scroll forward before repaint
- `-z n`, `--window=n` — set scrolling window size (default one screenful)
- `-~`, `--tilde` — display blank lines after EOF instead of tildes
- `-# n`, `--shift=n` — horizontal scroll amount (default half screen width; fraction allowed)

### Buffering

- `-b n`, `--buffers=n` — buffer space per file in KB (default 64; -1 unlimited)
- `-B`, `--auto-buffers` — disable auto buffer allocation for pipes (use only 64 KB)
- `-h n`, `--max-back-scroll=n` — max lines to scroll backward before repaint

### File Handling

- `-e`, `--quit-at-eof` — exit on second EOF
- `-E`, `--QUIT-AT-EOF` — exit on first EOF
- `-F`, `--quit-if-one-screen` — exit if file fits on one screen
- `-o file`, `--log-file=file` — copy pipe input to file (prompt before overwrite)
- `-O file`, `--LOG-FILE=file` — copy pipe input to file (overwrite without prompt)
- `-p pattern`, `--pattern=pattern` — start at first occurrence of pattern
- `-P prompt`, `--prompt=prompt` — customize prompt (see PROMPTS section)
- `-t tag`, `--tag=tag` — edit file containing tag (requires tags file)
- `-T file`, `--tag-file=file` — specify tags file (default "tags")
- `-k file`, `--lesskey-file=file` — use lesskey binary file
- `--lesskey-src=file` — use lesskey source file
- `-K`, `--quit-on-intr` — exit immediately on ^C (status 2)
- `-L`, `--no-lessopen` — ignore LESSOPEN for subsequently opened files

### Color

- `-Dxcolor`, `--color=xcolor` — set color for different text types (B, C, E, M, N, P, R, S, W, d, k, s, u)
- `--use-color` — enable colored text (required for -D uppercase letters)

### Miscellaneous

- `+"cmd"` — execute initial command (e.g., `+G` to start at end)
- `++"cmd"` — execute initial command for every file
- `--` — end of options; treat remaining args as filenames

## Commands

### Scrolling

- `SPACE`, `^V`, `f`, `^F` — forward one window (default)
- `z` — forward one window (sets new window size if N given)
- `ENTER`, `RETURN`, `^N`, `e`, `^E`, `j`, `^J` — forward N lines (default 1)
- `d`, `^D` — forward half screen (default); sets default for d/u
- `b`, `^B`, `ESC-v` — backward one window
- `w` — backward one window (sets new window size)
- `y`, `^Y`, `^P`, `k`, `^K` — backward N lines (default 1)
- `u`, `^U` — backward half screen (default); sets default for d/u
- `J` — forward beyond EOF
- `K`, `Y` — backward beyond BOF
- `ESC-)`, `RIGHTARROW` — scroll right N characters (default half screen)
- `ESC-(`, `LEFTARROW` — scroll left N characters
- `ESC-}`, `^RIGHTARROW` — scroll right to end of longest line
- `ESC-{`, `^LEFTARROW` — scroll left to first column
- `r`, `^R`, `^L` — repaint screen
- `R` — repaint and reload file
- `F` — tail -f mode (forward, wait for growth; stop with ^C)
- `ESC-F` — tail -f until match found, then ring bell and stop

### Navigation

- `g`, `<`, `ESC-<` — go to line N (default 1 = beginning)
- `G`, `>`, `ESC->` — go to line N (default end)
- `ESC-G` — go to last buffered line (stdin only)
- `p`, `%` — go to N percent into file (0–100)
- `P` — go to byte offset N
- `{`, `}` — go to matching curly bracket
- `(`, `)` — go to matching parenthesis
- `[`, `]` — go to matching square bracket
- `ESC-^F` — follow two chars as open/close bracket (forward)
- `ESC-^B` — follow two chars as open/close bracket (backward)
- `m` — mark first displayed line with letter
- `M` — mark last displayed line with letter
- `'` (single quote) — go to mark (letter, `'` for last large movement, `^` for BOF, `$` for EOF)
- `^X^X` — same as single quote
- `ESC-m` — clear mark

### Searching

- `/pattern` — forward search for N-th match (default 1)
- `?pattern` — backward search for N-th match
- `ESC-/pattern` — same as `/*` (forward across files)
- `ESC-?pattern` — same as `?*` (backward across files)
- `n` — repeat previous search forward
- `N` — repeat previous search backward
- `ESC-n` — repeat search forward across files
- `ESC-N` — repeat search backward across files
- `ESC-u` — toggle search highlighting
- `ESC-U` — toggle search highlighting and clear saved pattern

Pattern modifiers (prefix to pattern):
- `^N` or `!` — negate (lines NOT matching)
- `^E` or `*` — search multiple files
- `^F` or `@` — start from first/last file
- `^K` — highlight matches without moving
- `^R` — literal (no regex)
- `^W` — wrap around file

### File Management

- `:e [filename]` — examine new file (% = current file, # = previous)
- `^X^V`, `E` — same as :e
- `:n` — examine next file (N-th next)
- `:p` — examine previous file (N-th previous)
- `:x` — examine first file (N-th file)
- `:d` — remove current file from list
- `t` — go to next tag
- `T` — go to previous tag
- `=`, `^G`, `:f` — print file info (name, line, byte offset, percent)
- `-` — change option (followed by option letter)
- `--` — change long option
- `-+` — reset option to default
- `--+` — reset long option to default
- `-!` — toggle option to opposite of default
- `--!` — toggle long option to opposite
- `_` — show option setting (followed by letter)
- `__` — show long option setting
- `+cmd` — set initial command for each new file
- `V` — print version
- `q`, `Q`, `:q`, `:Q`, `ZZ` — exit

### Pipe and Shell

- `v` — edit current file with editor (VISUAL/EDITOR/vi)
- `! shell-command` — run shell command (% = current file, # = previous, !! repeat)
- `| <m> shell-command` — pipe section between mark and current screen to command
- `s filename` — save input to file (pipe only)

## Examples

shell
# View file with line numbers
less -N README.txt

# View with long lines chopped
less -S longfile.log

# Monitor growing log file (tail -f)
less +F /var/log/syslog

# Start at first occurrence of "error"
less -p error app.log

# Display ANSI colors (e.g., from git diff)
git diff | less -R

# Avoid clearing screen on exit
less -X file

# Define a custom prompt
LESS="-Pm?f%f :?pB%pB\%" less file

# Use input preprocessor for compressed files (assuming lessopen.sh)
LESSOPEN="|lessopen.sh %s" less file.Z
## See Also

- [lesskey(1)](http://localhost/phpMan.php/man/lesskey/1/markdown) — key binding customization
- [more(1)](http://localhost/phpMan.php/man/more/1/markdown) — simpler pager
- [vi(1)](http://localhost/phpMan.php/man/vi/1/markdown) — text editor
- [ctags(1)](http://localhost/phpMan.php/man/ctags/1/markdown) — tag generation for `-t`
- [global(1)](http://localhost/phpMan.php/man/global/1/markdown) — global tag support
- [less(3perl)](http://localhost/phpMan.php/man/less/3perl/markdown) — Perl pragma for requesting less resources

## Exit Codes

- 0 — normal exit
- 1 — error (e.g., file not found)
- 2 — interrupt with `-K` option

---

## less(3perl) — Perl Pragama

**Name:** less — Perl pragma to request less of something

**Synopsis:** `use less 'CPU';`

**Description:** A user-pragma that allows modules to adjust behavior based on requests for resource conservation (e.g., CPU, memory). If no feature is specified, defaults to 'please'.

**Module Author Interface:**
- `less->of('FEATURE')` — returns true if user requested less of that feature
- `less->of()` — returns list of requested features, or true if any requested

**Caveats:** Works only on Perl 5.10+. Probably does nothing.