Skip to content

Relative Line Numbering

Trevor Williams edited this page Apr 26, 2020 · 1 revision

Let’s face it — there’s something comforting about having line numbers displayed when editing text. It aids in debugging failures, it helps gives us a sense of where we are, and it even feels good to hit the return key at the end of a file and see the line number increase, giving us a feeling of accomplishment. All code editors have line number support as a result.

Vim not only has support for line numbers but they also have support for something called relative line numbering. TKE has this feature as well. Relative line numbers track the current insertion cursor. Whereever the insertion cursor is, that line is numbered ‘0’. The lines above the insertion cursor are incrementally increased from 0 while the lines below the insertion cursor are also incrementally increased from 0 as can be seen in the image below.


What is Relative Line Numbering Good For?

Relative line numbering is especially useful when operating in Vim mode as it allows aids commands like yanking, cursor movement, and the like. For example, if I want to move the cursor from its current position to the line containing the first “interp” line in the image above, I don’t have to manually count the lines, I can simply enter ‘7j’ as I can quickly reference the relative line number of the first “interp” line.

How Can I Enable It?

If you always want line numbering to start as relative, you go to the preferences window, click on the Editor panel and select the Enable Relative Line Numbering option. If you want to change the line numbering scheme in the current editing buffer, you can use the View / Line Numbering menu option to switch between “Absolute” and “Relative”. Additionally, you can use the Vim command :set rnu to use relative line numbering or :set nornu to use absolute line numbering.

Just another way that TKE has your back!

Clone this wiki locally