> ## Content Index
> Fetch the complete content index at: https://itsfoss.com/llms.txt
> Use this file to discover other available public pages before exploring further.

# Show Line Numbers in Vim
- URL: https://itsfoss.com/vim-line-numbers/
- Published: 2023-10-23T04:29:13.000Z
- Updated: 2023-10-23T04:29:13.000Z
- Description: Vim supports different kinds of line numbering. Here's how to enable them.
- Author: Sagar Sharma
- Tags: Vim, #hide

Want to show line numbers in Vim? 

Well, there are 3 types of line numbering in Vim:

- Absolute: Show line numbers starting from 1.
- Relative: Show line numbers from 0.
- Hybrid: Uses two columns and shows both absolute and relative numbers.

Here's how you can enable and disable them in Vim (make sure you are in normal mode before using them):

| Type     | Activate    | Deactivate      | Description                                                            |
| -------- | ----------- | --------------- | ---------------------------------------------------------------------- |
| Absolute | :set nu     | :set nonu       | Show number starting from 1.                                           |
| Relative | :set rnu    | :set nornu      | Your current line will always be noted as the 0th line.                |
| Hybrid   | :set nu rnu | :set nonu nornu | Shows the both relative and absolute numbers using two number columns. |

💡

You can make any of these permanent by editing the vimrc file.

Wanna know how? Here's how you do it.

## Enable absolute line numbering in Vim 

As I mentioned earlier, absolute line numbers will start from 0 and if you want to have that behavior, follow 2 simple steps to enable it:

1. Press `Esc` key to switch to normal mode
2. Press the colon key (`:`) and type `set nu` or `set number` and hit the `Enter` key

Confused? Here's how you do it:

![enable absolute line numbering in vim](https://itsfoss.com/content/images/2023/10/Enable-alsolute-line-numbering-in-Vim.gif)

Pretty easy. Right?

But what if you want to disable it? 

Well, for that, all you have to do is press the colon key `:` and type `set nonu` or `set nonumber` and it will disable the absolute number in Vim:

![Disable absolute line numbering in Vim](https://itsfoss.com/content/images/2023/10/Disable-absolute-line-numbering-in-Vim.gif)

### Make absolute line numbering permanent 

If you liked the absolute line numbering, you can make it permanent by making a few changes to the `vimrc` file. Let me show you how.

First, open the `vimrc` file using the following:

```
vi ~/.vimrc
```

Now, press the `i` key to get into the insert mode and type the following:

```
set number
```

![make absolute line numbering permanent in Vim](https://itsfoss.com/content/images/2023/10/make-absolute-line-numbering-permanent-in-Vim-1.png)

Once done, press the colon key `:` and type `wq` to save and exit from the Vim editor.

From now on, if you open any file with the Vim, you will see absolute numbering by default.

## Enable relative line numbering in Vim 

When enabled, it will show the current line a 0th line which is quite helpful as you don't have to do mental math and you can go to a specific line pretty easily.

To enable relative line numbering, you have to follow two simple steps:

- Press the `Esc` key to switch to normal mode.
- Press the colon key `:` and type `set rnu` or `set relativenumber` and then hit the `Enter` key.

Let me show you how you perform those steps in actual life:

![enable relative line numbering in Vim](https://itsfoss.com/content/images/2023/10/Enable-relative-line-numbering-in-Vim-editor.gif)

For some reason, if you want to disable it, all you have to do is press the colon key `:` and type `set nornu` or `set norelativenumber` and it will disable relative numbering:

![disable relative line numbering in Vim](https://itsfoss.com/content/images/2023/10/disable-relative-line-numbering-in-Vim.gif)

### Make relative line numbering permanent in Vim 

If you want to use relative line numbering every time you use Vim, it is a good idea to make it permanent. For that, you have to make some changes in `vimrc` file.

First, open the `vimrc` file using the following command:

```
vi ~/.vimrc
```

Now, press the `i` key to switch to insert mode and enter the following lines in the file:

```
set relativenumber
```

![Make relative line numbering permanent in Vim](https://itsfoss.com/content/images/2023/10/Make-relative-line-numbering-permanent-in-Vim.png)

To save changes and exit from Vim, press the colon key `:` and type `wq`.

From now on, you will see relative numbering every time you use Vim.

## Enable hybrid line numbering in Vim 

Hybrid line numbering is a blend of absolute and relative numbering and in my opinion, it gives you the best of both worlds. 

To enable hybrid line numbering, you need to follow two simple steps:

- Press `Esc` key to switch to the normal mode.
- Press the colon key `:` and type `set nu rnu` or `set number relativenumber` and then press the `Enter` key.

Here's how you follow two steps:

![Enable hybrid line numbering in Vim](https://itsfoss.com/content/images/2023/10/Enable-hybrid-line-numbering-in-Vim.gif)

For some reason, if you don't find it useful to your workflow, it can be disabled by simply pressing the colon key `:` and typing `set nonu nornu` or `set nonumber norelativenumber` and press the `Enter` key:

![Disable hybrid line numbering in Vim](https://itsfoss.com/content/images/2023/10/Disable-hybrid-line-numbering-in-Vim.gif)

That was quick. Isn't it?

### Make hybrid line numbering permanent in Vim 

To make hybrid line numbering permanent in Vim, first, open the `vimrc` file using the following:

```
vi ~/.vimrc
```

Now, press the `i` button to switch to insert mode and enter the following:

```
set number relativenumber
```

![Make hybrid line numbering permanent in Vim ](https://itsfoss.com/content/images/2023/10/Make-hybrid-line-numbering-permanent-in-Vim-.png)

To save changes and exit from Vim, press the colon key `:` and type `wq` , and hit Enter.

That's it!

## New to Vim? Let me help

I know Vim overwhelms you with the plethora of keybindings and an entirely different workflow than the other text editors but once you get a grip on it, there's no going back.

I will recommend you start by learning [what are the Vim modes](https://linuxhandbook.com/vim-modes/?ref=itsfoss.com):

[What are Vim Modes? How to Change Them?Vim has three different modes for handling user input and processing them.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookTeam LHB![](https://linuxhandbook.com/content/images/2022/04/vim-modes.png)](https://linuxhandbook.com/vim-modes/?ref=itsfoss.com)

Once done, learn some [basic keybindings of Vim](https://linuxhandbook.com/basic-vim-commands/?ref=itsfoss.com):

[Basic Vim Commands Every Linux User Must Know \[With PDF Cheat Sheet\]A comprehensive guide explaining basic vim commands that will be useful to any Linux user be it a sysadmin or a developer.![](https://linuxhandbook.com/content/images/size/w256h256/2021/08/Linux-Handbook-New-Logo.png)Linux HandbookAbhishek Prakash![](https://linuxhandbook.com/content/images/2020/06/basic-vim-command-guide-1.jpeg)](https://linuxhandbook.com/basic-vim-commands/?ref=itsfoss.com)

In the end, [learn some tips and tricks for Vim](https://itsfoss.com/pro-vim-tips/):

[8 Vim Tips And Tricks That Will Make You A Pro UserBrief: In this article, I’ll show you some of my favorites Vim tricks with practical examples. If you don’t use Vim, these tips might not give reasons for using Vim but if you use it already, you’ll definitely become a better Vim user. Even if I recently![](https://itsfoss.com/content/images/size/w256h256/2022/12/android-chrome-192x192.png)It's FOSSSylvain Leroux![](https://itsfoss.com/content/images/wordpress/2017/02/vim-tips-tricks.jpg)](https://itsfoss.com/pro-vim-tips/)

Want even more Vim? Opt for this Vim course:

![](https://itsfoss.com/content/images/2023/10/mastering-vim-quickly-book.jpg) 

#### Mastering Vim Quickly

Master Vim like a true professional with this highly rated, premium Vim book and training course.

[Chek it out](https://itsfoss.click/mastering-vim-quickly?ref=itsfoss.com) 

I hope you will find this guide helpful.