Table of Contents
1. Context
Knowing the commonly used vi
editor commands is absolute bliss. You can get your work done much faster with frequently used commands. In this article, I’ll share the commands to show line numbers in the vi
editor temporarily for a single session, and permanently as well.
2. Temporarily Show Line Numbers in vi
To temporarily show line numbers in vi
editor, in command mode type :set number
or :set nu
. To temporarily hide line numbers, in command mode type :set nonumber
or :set nonu
.
# Switch to command mode Esc # Show line numbers :set number # Alternate option to show line numbers :set nu # Hide line numbers :set nonumber # Alternate option to hide line numbers :set nonu
3. Permanently Show Line Numbers in vi
To permanently show line numbers in vi
editor, edit the file ~/.vimrc
and add the option :set number
or :set nu
at the end.
# Open ~/.vimrc in vi editor vi ~/.vimrc # Add option to show line numbers :set number # Add alternate option to show line numbers :set nu # Add option to hide line numbers (default behavior) :set nonumber # Add alternate option to hide line numbers (default behavior) :set nonu
4. Conclusion
In this article, you have learned how to show line numbers in the vi
editor temporarily for a single session or permanently. To work with the vi
editor like a pro, refer to this article: Work With vi Editor Like a Pro.
Join our list to get instant access to new articles and weekly newsletter.
[…] In this article, you have learned how to enable syntax highlighting in the vim ad vi editor. To work with vi editor like a pro, refer to this article: Work With vi Editor Like a Pro. To know how to go to a specific line in vi editor refer to this article: vi Show Line Numbers. […]