Setting Line Number in Vi/Vim

vim Line number

In case you don’t know, vi editor is the most widely used editor of all time by programmers and users alike. Vim is the improved version of vi and is the superset of vi in terms of its functionality, meaning all the functionality of vi is available in vimVim lets among other things to extend the editor’s functionality with plugins and hence can be turned into a “modern IDE”.

Let’s start our process of turning vi/vim into modern IDE by turning the line number on. To do so, you have to be in the normal mode or command mode. If you’re in insert or append mode, you can switch to normal mode by hitting Esc key. Once there, enter the command

:set number

To remove the line number, keyboard

:set number!

You’ll notice the line number in the editor. This change is temporary; to make it peramanent, add the following line to the .vimrc file in your home directory. If you haven’t find .vimrc in your home directory, create the same.

set number

Now vi/vim will have line numbers every time you open a file.

This guy demonstrates what I’ve said. Plus relativelinenumber. I didn’t know that…pretty cool!

About Deepak Devanand

Seeker of knowledge
This entry was posted in vi and tagged , , , . Bookmark the permalink.

One Response to Setting Line Number in Vi/Vim

  1. Pingback: Setting Autoindent in Vi(m) | Deepak's Kaleidoscope

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s