Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

How do I enable line numbers to be displayed in Vim?

share|improve this question
Work on your search skills. This functionality exists since the early versions of vi, i.e. for decades. There surely is some mentioning on teh Internets. – Ingo Karkat Oct 8 '13 at 8:20

To enable line numbering:

:set number

To disable it:

:set nonumber
share|improve this answer
short form for the same: :set nu and :set nonu – Hemant Sep 17 '10 at 18:20
Heck, :se nu and :se nonu if you really want to shave characters. But :set number and :set nonumber are pretty clear, aren't they? – ephemient Sep 17 '10 at 18:29

And if you want it to apply to every instance of Vim you open... put set number in your .vimrc file!

share|improve this answer
Or even your .exrc file, which will work for vim, nvi, vi, etc. – kurtm Oct 7 '13 at 21:30

I find it extremely useful to have a binding to toggle line numbering (among other things). It can be configured as follows

nnoremap <Leader>gn :setl number!<CR>:setl number?<CR>

The first command will toggle the line numbering for the current buffer (local) and the second one will display the current value of the option on the status line.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.