How to Hide Line Numbers in Vim Editor
Last Updated :
06 Dec, 2023
In this article, we will cover how to hide line numbers in the Vim editor. First, we look at what Linux and VIM editors and why we use them, what are its features and how can we use them followed by various options to make the Vim editor hide line numbers and how we can change the default settings of Vim editor to hide line numbers.
Linux
Linux was developed by Linus Torvalds in 1991 as a hobby project. It is an open-source (source code that can be used by anyone freely) kernel that is most popular and widely used in the industry as well as in personal systems. There are various operating systems based on the Linux kernel, some of the popular Linux distributions are Ubuntu, Cent OS, Red Hat, Debian, and Kali Linux.
VIM Editor
Vi Editor is a widely used text editor in Unix/Linux systems and is known for its efficiency and flexibility. Vi editor was developed in 1976 by Bill Joy and later in 1991, an improved version of Vi editor was released which is known as VI IMproved (VIM).
Hide line numbers in the Vim editor
First, we create an empty file and open it with the Vim editor,
vim filename.txt

Once the file is created add some text to it, press 'i' to enter in editing/insert mode, and start writing your content,

Follow the below steps to hide line numbers in the Vim editor:
- Enter in command mode, Press Esc if you are in insert mode
- Use the following command to hide line numbers,
:set nonumber
Alternatively,
:set nonu
Example:

- If you are using the relative line numbers use the following command to hide relative line numbers,
:set norelativenumber
Alternatively,
:set nornu
Toggle between Display and Hide line numbers
First we create an empty file and open it with the vim editor,
vim filename.txt

Once the file is created add some text in it, press 'i' to enter in editing/insert mode and start writing you content,

To toggle the absolute line numbers use the following commands:
:set number!
Alternatively,
:set nu!
Example:

To toggle the relative line numbers use the following commands,
:set relativenumber!
Alternatively,
:set rnu!
Example:

Configure Default Settings of vim editor
To change the default settings of vi editor, we have to configure the vi editor configuration file (.vimrc), to configure the default settings follow the below steps,
- Open the file in vi editor to configure it
vim ~/.vimrc
- Configure the default setting as per your requirements
- For example, if you want to hide the line numbers by default when you open the vim editor add the command set nonumber in the configuration file.

- When you are done with configuration Press Esc to exit the insert mode
- Use :wq command to save the changes and exit the editor

Conclusion
In this article we had covered the commands for hiding absolute line numbers, relative line number in vim editor, then how to toggle between display and hide line numbers and its command syntax along with the examples. At last we discussed how can we configure the default settings of the vim editor so whenever we opens the editor it loads with the default settings.
Similar Reads
How to Show Line Numbers in Nano Editor?
Nano is a popular and user-friendly text editor available on Unix-based systems, known for its simplicity and ease of use. While Nano provides essential features for text editing, such as syntax highlighting and search functionality, showing line numbers by default isn't one of them. However, it's p
3 min read
How to Display Line Number in vim editor in Linux
In this article, we will cover how to make the Vim editor display or hide line numbers. First, we look at what Linux and VIM editors and why we use them, are its features and how can we use them Follow the basic VIM editor guide to get familiar with the editor followed by various options to make the
5 min read
How to Highlight Text in Vim Editor in Linux
In this article, we will cover how to highlight text or syntax in Vim editor. First, we look at what Linux and VIM editors followed by syntax highlighting in the Vim editor with examples and screenshots we will also look at different color schemes available and how we can change the default settings
3 min read
How to Install Vim Editor in MacOS?
Vim editor is an open-source software developed by "Bram Moolenaar" in 1991. Vim, short for "Vi IMproved," is a highly customizable and powerful text editor that is most commonly used by developers, system administrators, writers, and anyone who works extensively with text files. Vim is created as a
3 min read
How to undo in Vim editor in Linux
Vim (short for Vi Improvised) is a popular text editor mainly used in Linux and Unix-based operating systems but due to having a CLI (command line interface), it might be difficult for new users to make use of basic features such as undo in Vim. So in this article, we will learn different ways and t
3 min read
Joining Two Lines in VI Editor
Vi is a powerful command-line text editor used by programmers, system administrators, and writers alike. They offer a vast array of features, including the ability to manipulate text efficiently. One common task you might encounter when working with Vi is joining two lines together. This article wil
3 min read
How to Exit Vim in Linux?
Exiting VIM quickly and easily can be done in multiple ways, depending on whether you want to save changes or quit from VIM without saving. Exiting VIM (a text editor commonly used in Linux) can confuse new users. Here's a step-by-step guide to help you exit VIM safely, whether you've made changes o
5 min read
How to Edit Multiple Files in Vim Editor in Linux
Vim, short for "Vi Improved," is a highly configurable and powerful text editor built upon the foundation of Vi. Like its predecessor, Vim offers robust support for editing multiple files simultaneously, making it an indispensable tool for developers, system administrators, and anyone working extens
4 min read
How to Indent Code in Vim Editor?
Vim is a popular text editor used by many developers for writing code, creating readme files, and writing scripts. It's open-source and offers a lot of ways to customize your experience. This makes it easier and more efficient to work with. Properly formatting and indenting your code is important be
4 min read
How to Edit Multiple Files in Vi Editor in Linux
Vi, short for "visual editor," is a powerful and ubiquitous text editor in the Linux ecosystem. Among its many features, one of the most useful is its capability to edit multiple files simultaneously. This ability streamlines the editing process, especially when dealing with projects that span multi
4 min read