Show line numbers in vim editor

December 21st, 2011 § 1 comment

I found Many of my friends are not aware of “how to show line numbers in vim editor”. So I thought of helping them by googling and share my finding here. So here is how we can show up line numbers in vim editor.

  • Show Line numbers
    Get into command mode in vim and run

    :set number

    or

    :set nu
  • Hide Line Numbers
    Get into command mode in vim and run

    :set number!

    or

    :set nu!
  • Always show line numbers while opening the file
    Open the file “~/.vimrc”. create it,if doesn’t exists
    Append “set number” to¬†~/.vimrc

Hope it helped you. Thanks

Revath S Kumar [RSK]

- Rubyist / JavaScripter - Yeoman Team member - Open source enthusiast - Blogger @ PHPRepo and http://blog.revathskumar.com - Coder @ Whatznear - Google fanboy - jQuery lover

More Posts - Website - Twitter - Facebook - LinkedIn - Pinterest - Google Plus - YouTube

Tagged

  • :set number! is actually a toggle. If number is set, number! turns it off. If number is not set, number! turns it on.

    This is a prime candidate for a key mapping:
    map :number!

    Replace with any function key or other key sequence not otherwise in use. Just put it in ~/.vimrc or _vimrc on Windows. Then, whenever you press the F5 key, line numbering is turned on or off.