diff --git a/README.md b/README.md index 9bef3d3..d05fb1c 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ working across different projects via [VisualMode](https://www.visualmode.dev/). For a steady stream of TILs, [sign up for my newsletter](https://visualmode.kit.com/newsletter). -_1717 TILs and counting..._ +_1718 TILs and counting..._ See some of the other learning resources I work on: @@ -1639,6 +1639,7 @@ If you've learned something here, support my efforts writing daily TILs by - [Different Ways To Generate A v4 UUID](unix/different-ways-to-generate-a-v4-uuid.md) - [Display All The Terminal Colors](unix/display-all-the-terminal-colors.md) - [Display Free Disk Space](unix/display-free-disk-space.md) +- [Display Line Numbers While Using Less](unix/display-line-numbers-while-using-less.md) - [Display The Contents Of A Directory As A Tree](unix/display-the-contents-of-a-directory-as-a-tree.md) - [Do A Dry Run Of An rsync](unix/do-a-dry-run-of-an-rsync.md) - [Do Not Overwrite Existing Files](unix/do-not-overwrite-existing-files.md) diff --git a/unix/display-line-numbers-while-using-less.md b/unix/display-line-numbers-while-using-less.md new file mode 100644 index 0000000..635ff3c --- /dev/null +++ b/unix/display-line-numbers-while-using-less.md @@ -0,0 +1,27 @@ +# Display Line Numbers While Using Less + +Including line numbers while viewing files with `less` can provide useful +context for understanding where you are within the file. This is especially true +if you've used `&` to filter down to lines that match a pattern. + +You can start `less` with line numbers with the `-N` flag (or `--LINE-NUMBERS` +if you really want to spell it out). + +```bash +$ less -N log/development.log +``` + +If you've already started up `less` and wish you had included line numbers, +there is no reason to restart it with the flag. Instead, toggle the line numbers +option on within the `less` process. To do this, type `-N`. It will prompt you +with `Constantly display line numbers (press RETURN)`. Hit enter and line +numbers will appear to the left of each line in the file. + +Similarly, to toggle line numbers back off within `less`, hit `-n` (lower-case +`n`), accept the prompt, and back off they go. + +Both of these (`-N`/`-n`) are options being set (toggled) via the `-` command. +There are many other options like these that can be configured within a `less` +session in the same way. + +See `man less` and find the `-` command and the available `OPTIONS`.