git diff or
git log starts the less program. Perhaps not the
fanciest tool but more powerful than you might expect.
This post details the arguments that can be passed to
and also how to navigate once less is running. Things not relevant
for git are omitted.
Your current configuration:
git config --get core.pager
If this returns nothing, there is room for improvement there!
Configure something sensible:
# Short version
git config --global core.pager "less -eFiJM~ -j3 --tabs=3"
# Not so short version
git config --global core.pager "less --LONG-PROMPT --tabs=3 --quit-at-eof --quit-if-one-screen --tilde --jump-target=3 --ignore-case --status-column"
: See all less commands.
Add a link to the man page and this topic is hereby extensively covered :)
Git defaults to
Default cursor is just a
: Show # bytes passed
: Show current lines displayed (ex: 1-57)
: Display line numbers
: Fold multiple empty lines to just one (doesn't fold empty + or - lines though)
: Truncate long lines instead of wrapping
: Set default window line size to x for PgUp/PgDown
: Case insensitive search
: Case insensitive search unless uppercase characters are found in the search pattern
: with X a number: Show search result X lines from the top of the screen
: Place * on lines with search results
: Exits less when reached end twice
: Exits less when first reached end
: Exits when output is less than 1 page
: Lines after end of file are blank, not ~
xp: Triggers for any number x followed by
xp: Also triggers when just pressing
- Omitted: Many keys can be combined with
Control for the same effect.
: Forward one line or x lines if x is provided
: Forward half a page. If x is specified it becomes the new default for d
: Forward a page. x is optional, if provided it sets the size of the page (once)
: Sets the size of x as the page size (in lines) for all subsequent calls of f, SPACE and PgDwn
: Forward to the end
: Backward one line or x lines if x is provided
: Backward half a page. If x is specified it becomes the new default for u
: Backward a page. x is optional, if provided it sets the size of the page (once)
: Sets the size of x as the page size (in lines) for all subsequent calls of b, PgUp
: Backward to the beginning
See searching parameters above for configuring case sensitivity.
: Search down for text or regex
: Search up
: Goto next match
: Goto previous match
: Search and show only the matching lines
: Save to file and inspect with your weapon of choice
: When the character pressed is on top of the page, scroll to its counterpart
: Go to x% position in document
: With x any character. Mark this position as x.
: Goto the position marked as x
: ESC followed by SPACE: continue scrolling after end of stream
: Exit less
: Clear screen afterwards?
After a few years of just using
PgDown I guess this research
was way overdue.