Setting line numbers in vim

Line numbers are not displayed by default in Vim, although they can be quickly enabled. This article will show you how to display or hide line numbers in Vim / Vi text editor.

Line numbering is helpful not only for navigating the code but also for other activities like pair programming, debugging scripts, code reviews, referring to a particular line, and more.

Set line numbers

Press the Esc key to switch to command mode.
Press : and the bottom left corner of the screen will see the movement of the cursor. Type set number or set nu and hit Enter. :set number
You can toggle the line numbers with :set number! or :set nu!

Bonus Tip

To move a specific line
:[LINE NUMBER] hit enter
Example to move the pointer to line 10 :10 and hit enter


Technology Python Programming Entertainment Python3 Linux Web-development Linux-mint Centos 7 Book
ziabs @ 14 Sep 2022