Assorted Less(1) Tips
5 hours ago
- #command-line
- #tips
- #less
- Operating on multiple files: You can directly provide one or more files to open with `less`.
- Adding files after starting: Use `:e file.h` to add another file to the argument list.
- Navigating multiple files: Use `:n` for next file, `:p` for previous file, and `:x` to rewind to the first file.
- Removing files: Use `:d` to delete the current file from the argument list.
- Jumping to a line-number: Use `«count»G` to jump to a specific line.
- Jumping to a percentage-offset: Use `«count»%` to jump to a percentage of the file.
- Searching: Use `/«pattern»` to search forward, `?«pattern»` to search backward, and modifiers like `!`, `*`, `@`, and `@*` for advanced search.
- Filtering lines: Use `&«pattern»` to filter lines matching the pattern, and `&!«pattern»` for lines not matching.
- Bookmarking: Use `m` followed by a letter to bookmark, and `'` followed by the letter to jump back.
- Bracket matching: Type `(`, `[`, or `{` to jump to the matching closing character, and vice versa.
- Toggling options: Use `-` followed by an option (e.g., `-S` for word-wrap) to toggle settings without restarting.
- Running external commands: Use `!` to invoke external commands like `!date` or `!bc`.
- Default options with $LESS: Set common options in your shell startup file (e.g., `LESS="-RNe"`).
- Editing the current document: Use `v` to open the current document in your `$VISUAL` editor.
- Log output: Use `o` or `O` to redirect `less` output to a file.