Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to make VIM display line numbers?

I have the need to analyze very large files in VIM (only command mode I can use). Is it possible to configure VIM to display line numbers?

like image 878
user810430 Avatar asked Nov 06 '11 13:11

user810430


People also ask

How do I view line numbers in vi?

If you're already in vi, you can use the goto command. To do this, press Esc , type the line number, and then press Shift-g . If you press Esc and then Shift-g without specifying a line number, it will take you to the last line in the file.

How do I show line numbers in less command?

You can easily display line numbers using less command. All you have to do is pass either -N or --LINE-NUMBERS option to the less command. This option forces less to show a line number at the beginning of each line in the screen.

How to show line numbers in Vim?

To show line numbers in Vim, use the :set number command for absolute line numbers, :set relativenumber for relative line numbers. If both absolute and relative line numbers are enabled Vim switches to the hybrid line numbering mode. Feel free to leave a comment if you have any questions.

What is relative line mode in Vim?

Relative line mode is handy because many Vim operations, such as moving up/down and deleting lines work on relative line numbers. For example, to delete the next ten lines below the cursor, you would use the d10j command. With relative line numbers enabled you’ll have a better visual overview on the code.

How do I add a number to a line in Unix?

To activate the line numbering, set the number flag: Press the Esc key to switch to command mode. Press : (colon) and the cursor will move at the bottom left corner of the screen. Type set number or set nu and hit Enter.

How do I set the line numbering on the keyboard?

To activate the line numbering, set the number flag: 1 Press the Esc key to switch to command mode. 2 Press : (colon) and the cursor will move at the bottom left corner of the screen. Type set number or set nu and hit... 3 Line numbers will be displayed at the left side of the screen: More ...


2 Answers

Do :set number to display line numbers.

like image 66
davidscolgan Avatar answered Sep 29 '22 13:09

davidscolgan


:set nu shortcut of doing the same thing as :set number. unset it with :set nonu. Type :help nonu for more info.

like image 30
Vihaan Verma Avatar answered Sep 29 '22 12:09

Vihaan Verma