BLUE
Profile banner
CK
Chris Krycho
@chriskrycho.com
Software craftsman. Theologian, writer, runner, composer, photographer. Prev. @ LinkedIn; Ember.js TypeScript and Framework alum. My real home online is always www.chriskrycho.com.
184 followers56 following806 posts
CKchriskrycho.com

ā€¢ You can work with multiple files! I had no idea. There are commands to skip to/search across/etc. multiple filesā€”`:n` for next file and `:p` for the previous fileā€”even just straight-up open a new file from within the current session (`:e`).

1
CKchriskrycho.com

If you want to search *backward*, you can use `?` instead of `/`. (Mnemonic: `/` is `Shift-/` on a US English keyboard.) You can also modify the search query with flags before the search term, e.g. to find lines which donā€™t match (`!` or `^N`), wrap at the end (`^W`), etc.

1
CKchriskrycho.com

ā€¢ Search: you type `/` and then provide regex-ish syntax. Once youā€™re in that mode, `n` goes to the next match and `p` to the previous. Interestingly, `less` remembers that across sessions! (Other tools might as well, but `less` is the main one where I notice that behavior.)

1
CKchriskrycho.com

ā€¢ Jump to matching brackets: type the *opposite* bracket to get to the matching bracket, so `{` jumps to a matching `}` if the top line in the screen has a `{` in it; the same thing works for () and [].

1
CKchriskrycho.com

There are also variants of these which let you scroll past the start or edge of the pageā€¦ as will the totally-new-to-me `ā†’` and `ā†` (or `Esc-(` and `Esc-)`) commands to scroll right or left. I guess that makes sense, but since things usually get auto-wrapped, I never knew!

1
CKchriskrycho.com

ā€¢ Which applies more generally: you can stick `N` in front of *lots* of commands and it will affect the resulting ā€œsizeā€ of the operation. Want to go down by just 8, and make that the default? `8d` will do it. `12u` will go up in the file by 12 lines and set the default.

1
CKchriskrycho.com

ā€¢ You can change how big the ā€œscreenā€ is. This does not change anything about the amount displayed on screen (thatā€™s up to your terminal), but rather how big a ā€œscreenā€-sized is. You can set it to (e.g.) 8 lines explicitly with `-z8` or by preceding `z` with a number of lines.

1
CKchriskrycho.com

Some things you can do with it: ā€¢Ā Move forward and backward in a file, as promised by the description. `Space`, `^V`, `f` and `F` all go forward by a screenful. `b` and `^B` and `ESC-v` (or `Meta-v`) go backward by a ā€œscreenā€. But ā€œscreenā€ is in quotes for a reason:

1
CKchriskrycho.com

As with many Unix commands, the ā€œjust do one thingā€ philosophy isā€¦ not really intact. It accepts most of the upper- and lowercase English alphabet as flags, in most cases modifiable with `+`, for something around 80 individual ways you can invoke it. Many of them combinable!

1
CKchriskrycho.com

A better summary: `less` displays a file in your terminal, page by pageā€”thus, a ā€œpagerā€ā€”with navigation commands stolen from `more` and `vi`ā€¦ so good luck quitting! The way out is to hit `q`, but the man page does not tell you that, perhaps assuming you know `more` and `vi`.

1
Profile banner
CK
Chris Krycho
@chriskrycho.com
Software craftsman. Theologian, writer, runner, composer, photographer. Prev. @ LinkedIn; Ember.js TypeScript and Framework alum. My real home online is always www.chriskrycho.com.
184 followers56 following806 posts