Learn Vim / How to Show Line Numbers in Vim

How to Show Line Numbers in Vim

The answerRun :set number. For numbers relative to the cursor (which make counts like 5j effortless), run :set relativenumber.

Most vim users run both together: absolute number on the cursor line, relative everywhere else. Add set number relativenumber to your vimrc.

All the ways

KeysWhat it does
:set numberabsolute line numbers
:set relativenumberdistances from the cursor
:set nonumber norelativenumberturn both off
:set nu rnuthe short forms
▶ live vim buffertarget 5 keystrokes
Counting j presses is for tourists. Jump straight to line 10 with 10G (or :10 and Enter), then delete that line with dd.

Reading about keystrokes doesn't build keystrokes. Try this in a real vim buffer right now — the “Teleportation” mission takes about a minute.

Sign in free to practice →

Keep going