Re:Numbers.vim - better line numbers for vim
by masukomi on Thursday June 28, 2012 @12:15PM
(#4172386)
I just have this in my .vimrc which lets you toggle it whatever way you want in edit mode and it stays however you leave it when you toggle modes
" use Ctrl+L to toggle the line number counting method
function! g:ToggleNuMode()
if(&rnu == 1)
set nu
else
set rnu
endif
endfunc
nnoremap <C-L> :call g:ToggleNuMode()<cr>Quick note: This requires vim 7.3
Re:Numbers.vim - better line numbers for vim
by fsaintjacques on Thursday June 28, 2012 @01:16PM
(#4172710)
Thank you for sharing!
Re:Numbers.vim - better line numbers for vim
by SkyMarshal on Thursday June 28, 2012 @03:27PM
(#4173445)
One benefit of the plugin approach is that it will get forked and improved and other cool and useful things added to it. It's a central repository for all of that goodness, and keeping it up to date just requires pulling the repo (assuming you're using Pathogen or Vundle), instead of remembering to dig through vim.org/scripts periodically.
TLDR - the plugin approach gains the benefits of software evolution.
Re:Numbers.vim - better line numbers for vim
by jamesrcole on Thursday June 28, 2012 @12:48PM
(#4172556)
You don't need one. It's a cost/benefit thing - is it worth having one? Do you really need to use Vim or Emacs or Eclipse, etc? You don't need to.
I can imagine some reasons why it might be useful to have it as a plugin. Making a plugin means giving it a name and a URL (and if it's on vim.org, a place in a well-known directory), and that makes discovery and communication of its existence easier. The fact that it's useful to have a gist for it bears this out, I think. I can't think of why it's that bad a thing to have a plugin for it.
Re:Numbers.vim - better line numbers for vim
by joshcorbin on Thursday June 28, 2012 @11:46AM
(#4172227)
Also useful to hook BufLeave/BufEnter and WinLeave/WinEnter imo.
Re:Numbers.vim - better line numbers for vim
by googletron on Thursday June 28, 2012 @11:36AM
(#4172172)
yeah, one because you forgot to surround it with an auto group. Plus its lines you don't have to write yourself.
If you want relative numbers to appear when in normal mode, and absolute line numbers to appear otherwise (e.g., when the window has lost focus), just throw this in your .vimrc:
Here's a gist for posterity. Feel free to fork it, leave comments on what should be changed, etc. The above has worked for me on Mac OS X for years, but there's a chance I didn't set it up the "right way". Leave comments on this gist and I'll update as necessary:https://gist.github.com/3012145