Wikia

Vim Tips Wiki

Display line numbers

Talk2
1,610pages on
this wiki
Revision as of 18:32, December 13, 2012 by 109.186.83.232 (Talk)

Tip 19 Printable Monobook Previous Next

created February 25, 2001 · complexity basic · author scrott · version 5.7


This will display line numbers along the left side of a window:

:set number

or:

:set nu

This will turn off the line number display:

:set nonumber

or:

:set nonu

You can also define a mapping to toggle the option, for example:

:nmap <C-N><C-N> :set invnumber<CR>

By pressing Ctrl-N twice in normal mode, Vim toggles between showing and hiding line numbers.

If you have Vim version 7 or greater, you can change the width of the "gutter" column used for numbering:

:set numberwidth=3

You can use the number column for the text of wrapped lines:

:set cpoptions+=n

Finally, you can change the color used for the line numbers. For example:

:highlight LineNr term=bold cterm=NONE ctermfg=DarkGrey ctermbg=NONE gui=NONE guifg=DarkGrey guibg=NONE

References

Comments

Advertisement | Your ad here

Around Wikia's network

Random Wiki