Wikia

Vim Tips Wiki

Display line numbers

Talk0
1,599pages on
this wiki
Revision as of 18:24, January 17, 2013 by Fritzophrenic (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Tip 19 Printable Monobook Previous Next

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


Contents

Enabling/Disabling Line Numbers in Vim Edit

EnablingEdit

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

:set number

or:

:set nu

DisablingEdit

This will turn off the line number display:

:set nonumber

or:

:set nonu

or:

:set nu!

Creating a Mapping to Toggle Line NumbersEdit

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.

Enabling Line Numbers on StartupEdit

To enable line numbers on startup, simply add the following to your .vimrc

 set number

or:

set nu

Adding Line Numbers Only to Certain FilesEdit

Create a filetype plugin for each filetype where you'd like to have numbering enabled (see :help ftplugin-overrule) and add the following line to it:

setl number

Changing Gutter Column WidthEdit

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

ReferencesEdit

CommentsEdit

Advertisement | Your ad here

Photos

Add a Photo
103photos on this wiki
See all photos >

Recent Wiki Activity

See more >

Around Wikia's network

Random Wiki