In this article, I will show you how to quickly show and hide line numbers in the Vim editor on Linux. When you are editing config files like php.ini or nginx.conf, being able to see the exact line number makes it much easier to follow error messages, share snippets with other developers, and jump straight to the problem line.
We will look at the simple Vim commands that control line numbers so you can turn them on when you need them and hide or remove them when you prefer a clean screen. Everything is done from the Linux terminal using the standard Vim command mode, with short examples you can copy and paste into your own sessions.
Show line numbers while using the Vim Editor
First, let’s open a file using the vim command. In this example, I will open the php.ini file located at /etc/php.ini
vim /etc/php.iniNext, let’s show the line numbers in the vim editor. This can be useful for debugging and quickly finding the exact line of the issue or error that you are debugging.
The first step is to hit the escape button to ensure you are not in editing mode. Next, type the : symbol. Finally enter the following command: set number. It should look like the following in your terminal window while using the vim editor.
<code>:set number</code>You should now notice that the line numbers are being displayed.
Hide line numbers while using the Vim Editor
You may be asking, how do I hide the vim line numbers? It’s very simple! Simply do the same thing as before, except this time we will set the value to nonumber instead.
<code>:set nonumber</code>I hope this post was helpful! If this post helped you, please consider sharing this post and/or leaving a reply below.






