Background
Line number come in very handy when you are working with any Text Editor. However if you take vi or vim editor then line numbers are hidden by default. In this post we will see how we can turn it on.
How to display or hide line numbers in vi or vim text editor
This post assumes you are a vim user and are aware of basic usage. Like for example when you need to save and quit data in vim you-
- press escape followed by :wq
or if you want to exit without saving
vi support a lot of commands to use and options to be set by using
colon (:)
To show line numbers in vi simple type below are pressing escape -
To hide it you can type -
This you need to do every time you launch into vi editor. To make it default edit your file at location
~/.vimrc and append following line at the end -
NOTE : You can create this file if it does not exist already.
Now you will always get line numbers when you launch vim editor.
Now that we have seen how to hide and display line numbers in vim editor lets see how we can jump to a particular line in vim -
How to jump to a particular line in vim
This is also fairly simple. Once you have launched vim you can simply move to any line number using following command -
Eg.
You can ever jump directly to your line number immediately as you open vim. To do that use following command while opening vim -
Eg.
This should open your file and move to the linenumber you have provided.
General Info
vim provides a lot of configurable options to set. To see them all type following command -
To see everything that you have set so far you can type following command -
For me it is as follows -
Related Links