Vim: display line numbers when terminal has enough columns

This snippet added to your .vimrc will show line numbers assuming you have >84 columns available.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
" I like having line numbers on, but don't want to wrap lines in a
" standard-sized terminal window.
fun! WinSizeAutoNumber()
    if winwidth(0) > 84
        set number
    else
        set nonumber
    endif
endfunction

" Run once on startup
call WinSizeAutoNumber()

" Run when window is resized
au VimResized * call WinSizeAutoNumber()