Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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
add comment

3 Answers

To enable line numbering:

:set number

To disable it:

:set nonumber
share|improve this answer
4  
short form for the same: :set nu and :set nonu –  Hemant Sep 17 '10 at 18:20
7  
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
add comment

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
add comment

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
add comment

Your Answer

 
discard

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.