Set Vim to Show Line Numbers By Default

It’s quite simple really. If you didn’t know how to show line numbers in vi(m), it is by typing the following command when you’re in the application:

:set number

But that doesn’t persist when you exit out of the text editor. When vi(m) launches, it reads settings from a file called .exrc in your user’s home directory, so we can add the setting as a default by executing this into the command line:

echo set number >> ~/.exrc

When you next open vi(m), line numbers will appear by default.

Leave a Reply