Monday, November 10, 2014

Re: Changing line numbers from normal to relative



On Mon, Nov 10, 2014 at 8:59 AM, Ben Fritz <fritzophrenic@gmail.com> wrote:
On Sunday, November 9, 2014 11:53:38 AM UTC-6, Eric Christopherson wrote:
>
> Great idea! But I find it only works in the terminal when I call the map
> <C-@> (even though my terminal treats C-Space as C-@).
>
> If I use <C-Space> as the map name, when I try the <C-Space> combination
> in one of those modes, I just get a bell. I tried running Vim with
> -V20vim.out to log what's going on, and it didn't show that CycleLNum()
> was ever called.

Weird. What does Vim see in insert mode when you do <C-V><C-Space>? It works fine for me in gvim in Windows, and it was a free key...that's the only reason I chose it. Use what works, I guess. :-)

>
> Two other minor quibbles here:
> - it doesn't reset the old numbering style after a motion or visual
>   operation has been done.

Yes, this mapping was intended to cycle through on a more permanent basis for my use. You could store the original line numbering in a variable and restore it in a second mapping if you like. Or restore it in a CursorHold/CursorMoved autocmd.



I'm exclusively a GVim user on Windows; the control-Space mapping gave me no trouble.

I always have line numbering on, so I changed the function to simply toggle 'relativenumber' as I didn't need it to cycle through the various options. Actually, I already had a mapping for this, but not one that used the <expr> mechanism to work in operator-pending mode, which was the boon here.

Usually, I don't care for the numbers; when I do, it's easy enough to hit the mapping to change it--I just didn't want to start an operation and then hit escape to change the number format and then come back, a problem Ben has helped quite a bit.

--
 
Salman

I, too, shall something make and glory in the making.

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment