Oh, line numbers. It’s one of the surprising joys of writing in a text editor. But many writers ignore line numbers. I understand. We think in sentences and paragraphs.
But, as I argued in a previous article about writing one sentence per line, you can (and should) think in lines. There are certainly benefits to this approach, and I mentioned flipping a certain variable in Emacs for relative line numbers.
Let’s learn how to do that now.
Table of Contents
What Are Relative Line Numbers?
Before we get into the why and how it’s important that you understand what relative line numbers are.
By default, your text editor likely displays absolute line numbers. It starts at the top with line 1 and goes down to whatever. But with relative line numbers, your current line is 0, and the text editor counts up in either direction. You can see in the image below, that I’m currently on line 17, and we have 1s on either side.
Benefits of Measuring Lines
This is good for writers who want to measure lines. As I mentioned, writing one sentence per line is a great way to quickly see how many sentences you have in a paragraph.
(If poets get this granular, why not prose writers? No, seriously.)
Also, you’re working on a computer. So you’re not literally “measuring” or counting lines one by one. The computer is calculating it for you.
How To Enable Relative Line Numbers
You can accomplish the magic relative line numbers trick by turning on the variable display-line-numbers
.
M-x customize-variable
Choose the variable: display-line-numbers
.
Set the value to Relative line numbers
:
For those who like to set variables with Emacs lisp, you can do it this way:
(setq display-line-numbers 'relative)
Well done! You just executed this article perfectly. And the benefits have been installed in your brain.
As always, if you have any comments or questions feel free to leave them below, and I will do my best to answer.
Leave a Reply