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?
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.
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.
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.
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.
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.
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 ...
Do :set number
to display line numbers.
:set nu
shortcut of doing the same thing as :set number
. unset it with :set nonu
. Type :help nonu
for more info.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With