
Numbers.vim - better line numbers for vim - mccarthyjm
http://myusuf3.github.com/numbers.vim/
======
theli0nheart
Do you really need a plugin for this?

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:

    
    
        set rnu
        au InsertEnter * :set nu
        au InsertLeave * :set rnu
        au FocusLost * :set nu
        au FocusGained * :set rnu
    

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>

~~~
masukomi
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>

~~~
RegEx
Quick note: This requires vim 7.3

------
blackRust
As someone with a low-bandwidth connection and that I often work in cafés I
hate it when the only description available is through video when there could
easily have been text and screenshots.

~~~
SkyMarshal
Even on high bandwidth connections it's annoying. My read speed is much higher
bandwidth than videos for things that can be explained in a paragraph or
three.

Videos should probably be used when:

1\. Your audience is non-technical.

2\. A (moving) picture is worth a thousand words (eg, words can't do it
justice, but a quick video can).

3\. You're not bandwidth constrained (or firewalled).

4\. You're not just video'ing text entry, or if you must, you ensure the user
can zoom in or enlarge the video to see it (the embedded video can't be
enlarged, I had to open it in Youtube to actually see it).

------
scott_w
I know some people like line numbers, but personally, I just look at the
status bar at the bottom of the buffer.

I find line numbers on the side clutter up my view too much. I always use 80
character terminal widths, to make it easier to stick to my PEP8 validation
script we run.

~~~
dionidium
That's fine for determining what line you're on, but visible line numbers make
it much easier to jump to a particular line. I've only recently _set number_
in my .vimrc and wish I'd have done it sooner.

~~~
ori_b
I do that by jumping to the particular line. :<linenum> or <linenum>G does
that.

~~~
hesitz
I think the point is that it's harder to see what line number you want to jump
to if you don't have line numbering on. . . .

~~~
Scriptor
Right, the alternative is to just sort of guess how much you need to ctrl-u/d
or j and k to get to a specific line. Also, I guess it depends on screen size.
I usually have plenty so the line numbers' usefulness outweighs the extra
space required, at least for me.

------
ilja
There's also <https://github.com/jeffkreeftmeijer/vim-numbertoggle> which
seems to do the same thing. I've been using that for a few months but i'm
still not sure it's actually an improvement. It gets in the way almost as much
as being actually useful.

------
foobarboomoo
FWIW, the example you give would be more easily handled with the built in
"dap" (delete a paragraph)

~~~
DougBTX
Yea, that's what I had in mind while watching the video too. I remember that
example as delete around paragraph, to match delete inside paragraph (dip),
which differ in how they handle whitespace at the end of the paragraph. Delete
inside quotes, di', and delete around quotes, da', work in the same way too.

------
joshcorbin
I'm still pondering the "how is this useful?" part... why are absolute numbers
useful for you in insert mode?

~~~
solutionyogi
My exact thought. I absolutely love 'relative line numbering' as it lets me
use different VIM commands without having to do math. And as I can go to any
line number by typing ':<line number>' [generally reported by debugger or
other means], I don't really care about actual line numbers anymore.

~~~
pwf
I still feel like I have to do math (albeit simple math) with relative line
numbering. If I want to yank a block of code that's X lines long, I have to
look at line X, and add one to the number next to it. E.g., when I want to
grab 8 lines, the last line I want to grab has a 7 next to it.

I guess I think it'd be more helpful if the numbers were inclusive, and
1-indexed. I'm not sure how to configure that though.

~~~
solutionyogi
Yes, I wish the numbering was 1-indexed. But by now, I have trained my brain
to automatically add one. I would definitely prefer a fix where I don't have
to do +1.

------
ary
Actually I'm more interested in seeing this guy's tmux config file.

~~~
hoov
He's got that on github, too:
<https://github.com/myusuf3/dotfiles/blob/master/tmux>

------
kamaal
Its these kind of things that I wish to see vanilla vim shipped with, without
bothering the user much.

Yes you can toss some commands and code snippets at me and ask me to use them
to get these features. But not having to type commands/snippets and have all
goodies out of the box is what modern text editors like sublime text are all
about.

~~~
rhizome
If you don't like typing, vim is not the right editor for you!

~~~
__float
There's a difference in productive typing and typing to set up your editor. I
would compare this to the popularity in Ubuntu vs Arch, too.

~~~
rhizome
Well, it's not like it's Eclipse. I've been carrying my .vimrc and other
dotfiles around from machine to machine for a decade. Occasionally I make
changes, but for the most part there's not a lot of setup with vim for me.

------
gaving
Anyone else just use visual mode for that kinna stuff?

------
outworlder
What's with the funky status bar?

~~~
mgrouchy
Thats his tmux Theme(outer) inner is powerline for
Vim(<https://github.com/Lokaltog/vim-powerline/>), with a patched font.

~~~
fsniper
That's what I was looking for. I love HN comments

