YouTube Icon

Code Playground.

How to Show Line Numbers in Vim / Vi

CFG

How to Show Line Numbers in Vim / Vi

Vim/Vi is the word processor of decision for some product designers and Linux framework chairmen. 

As a matter of course, Vim doesn't show line numbers, yet they can be handily turned on. Vim underpins three methods of line numbering that causes you explore through the records. Notwithstanding the standard outright line numbering, Vim additionally bolsters relative and half breed line numbering modes. 

This article will tell you the best way to show or conceal line numbers in Vim/Vi content tool. 

Other than exploring the code, line numbering is likewise valuable in different circumstances, for example, pair programming, investigating contents, code audits, alluding to a particular line, and then some. 

Also Read:-How to Submit Multiple Form array in Codeigniter using Ajax

Absolute Line Numbers

The total line numbering is the standard line numbering, which shows the suitable line number close to each line of text. 

To initiate the line numbering, set the number banner: 

Press the Esc key to change to order mode. 

Press : (colon) and the cursor will move at the base left corner of the screen. Type set number or set nu and hit Enter. 

:set number

 Line numbers will be shown at the left half of the screen: 

To handicap the outright line numbers off, run the :set nonumber or set nonu orders: 

:set nonumber
Also Read:-Captcha Code in Codeigniter and jQuery

You can likewise flip the line numbers with :set number! or on the other hand :set nu!: 

:set number!

Relative Line Numbers

At the point when the overall line numbering is empowered, the current line is appeared as 0; The lines above and beneath from the current line are steadily numbered (1, 2, 3, and so forth) 

Relative line mode is convenient on the grounds that numerous Vim activities, for example, climbing/down and erasing lines chip away at relative line numbers. 

For instance, to erase the following ten lines underneath the cursor, you would utilize the d10j order. With relative line numbers empowered you'll have a superior visual review on the code. 

Also Read:-How to send email with an attachment using Codeigniter

To empower the overall line numbering, change to the order mode and enter :set relativenumber or :set rnu: 

:set relativenumber

To handicap the general line numbering, type :set norelativenumber or set nornu: 

:set nonumber

To flip the general line numbering, utilize the :set relativenumber! or then again :set rnu! order: 

:set number!

Hybrid Line Numbers

In Vim 7.4 and later, empowering both the total and relative line numbers simultaneously sets up the crossover line number mode. 

Crossover line numbering is equivalent to the general line numbering with the main distinction being that the current line as opposed to demonstrating 0 shows its supreme line number. 

Also Read:-How to create array and insert record in mysql database using Codeigniter

To turn on the half and half line numbering, run both the number and relativenumber orders: 

:set number relativenumber

The equivalent can be accomplished by showing the orders coordinated: 

:set number 
:set relativenumber

To cripple the mixture mode, you'll have to kill both the total and relative numbering. 

Also Read:-Codeigniter 3 - select2 ajax autocomplete from database example with demo

Permanent Settings

On the off chance that you need line numbers to show up each time you dispatch Vim, add the proper order to your .vimrc (Vim arrangement record). For instance, to empower supreme line numbering, you would add the accompanying: 

vim ~/.vimrc

~/.vimrc

:set number

Also Read:-How to get current url with query string in codeigniter?

Conclusion

To show line numbers in Vim, utilize the :set number order for outright line numbers, :set relativenumber for relative line numbers. On the off chance that both supreme and relative line numbers are empowered Vim changes to the cross breed line numbering mode. 

Don't hesitate to leave a remark on the off chance that you have any inquiries.




CFG