Peter's Blog

Redefining the Impossible

Vim Line Numbers


I've been vimming a lot recently yet I haven't given any vim tips for an eternity.

With this in .vimrc/_vimrc:

set numberwidth=5
set numbers

vim shows line numbers on each line. I've held out against this for years but now I'm using >= 22" widescreen monitors I am converted.

The only problem is when I am vimming over an ssh tunnel (which I do a lot to maintain PetersBlogger) and I want to copy and paste: the pasted stuff includes the line numbers. When this crops up I do

:nonumber

to turn it off (kinda like doing a :noautoindent before pasting indented code).

UPDATE: this is even better if the background of the line numbers is changed so you can clearly see the gutter they are in:

:color murphy
:hi LineNr guifg=white guibg=darkgreen
:hi LineNr ctermfg=white ctermbg=darkgreen
images/VimLineColor.gif

Filed under: vim

Spikeles Says:

10 months ago

When i was at uni a had an awesome VIM config, i've lost it though :(

I remember i had: set nowrap syntax on set ruler set showcmd

And a bunch of others. A quick google search turned up daniel-werner.info/vimrc.html which seems decent enough. Will have to give it a try. I remember the rest of the uni was taught pico.. ughhh..

Kenneth Miles Says:

8 months ago

Thank you very much for sharing this tip which I have now implemented into my vimrc file.

Comments are Closed