![]() ![]() The same goes for ":set nonumber!" command. If you want changes to be permanent, you can save your preferences in a '.vimrc' file that lives in your user's home directory. Open the '.vimrc' file using your favourite text editor - vim ~/.vimrc.Next time you open Vim, you will always see absolute line numbers in Vim. If you no longer wish to have them, simply delete the line 'set number' from your user's '.vimrc' file. ![]() When you have relative line numbers enabled, it means that the line you are currently on is line number 0 and the lines above and below the cursor are consecutively numbered 1, 2, 3. This is particularly useful because moving the cursor up and down x number of lines gets easier. Showing relative line numbers in Vim from an active Vim session You do not have to do the mental math of subtracting the current line number from the line number, and you can go to a specific line in Vim easily. There should be a colon character printed to the bottom-left corner of Vim. Now type 'set relativenumber', or you can type 'set rnu' (for short) and hit the Enter key. You will see relative line numbers to the above and below the line that your cursor is on.įor any reason, if you do not end up liking it, you can turn off relative line numbering using the ':set norelativenumber' command or with 'set nornu' command for short. This will entirely disable the left column that shows the line numbers. ![]() The same nifty trick applies for relativenumber: If the relative line numbers are turned off, you can turn them on using ':set relativenumber!' or with ':set rnu!' command for short. If the relative line numbers are already toggled, setting this option will disable relative line numbers. You tried relative line numbers, and you liked it. You are wondering how to make this change permanent, instead of typing ':set relativenumber' every time you open Vim. To make this permanent, you need to set this option in your user's 'vimrc' file. Open the '.vimrc' file using Vim: vim ~/.vimrc.Type set relativenumber in '.vimrc', save and exit out of it.Now, when you will open Vim, you will always have relative line numbers enabled. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |