Vi

From TheBestLinux.com
Revision as of 10:01, 13 August 2014 by Jamie (talk | contribs) (Created page with "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 N...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
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