Vi

From TheBestLinux.com
Jump to navigation Jump to search

Vi & Vim Tips & Tricks

Toggle line numbering on:

set nu OR :set number

Toggle line numbering off:

set nonu OR :set nonumber 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