Tell me more ×
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

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
6  
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 vim you open...put "set number" in your .vimrc!

share|improve this answer

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

 
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.