plugin for toggeling line numbers

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

plugin for toggeling line numbers

trialero
hi,

I found a site where a vim plugin was used for relative line numbering
and I want to give it a try. relative line numbers make it easier to
navigate in normal mode by just using `3j' instead of `256G'. the less
keystrokes the better!

vimawsome.com has two variants: `numbers.vim' and `vim-numbertoggle'.

from the description both work the same and I installed `numbers.vim'.
this one even shows relative line numbers in mutt (and vim as editor)
while browsing the email in normal mode -- nice!

does anybody have experience with both of them? I'd be curious on your
opinions! maybe there is a third one that is niftier, I'd like to know.

TIA

//meine

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: plugin for toggeling line numbers

Erik Christiansen
On 07.04.19 13:51, meine wrote:
> hi,
>
> I found a site where a vim plugin was used for relative line numbering
> and I want to give it a try. relative line numbers make it easier to
> navigate in normal mode by just using `3j' instead of `256G'. the less
> keystrokes the better!
...
> does anybody have experience with both of them? I'd be curious on your
> opinions! maybe there is a third one that is niftier, I'd like to know.

No experience with plugins, but just this in .vimrc does it for me:

noremap <F1> :call Rnu_toggle()<CR>        " Toggle relative line numbering.
"
" Toggle relative line numbering.
function! Rnu_toggle()
    if &rnu == 1
     set nornu
  else
     set rnu
  endif
endfun

Someone on another list needed it for absolute line numbers - took out
the 'r' in each set, and he was good to go.

And, yes, using vim here in mutt, it's available too - after all vim
reads the same .vimrc when run here.

Relative line numbering really shines when you do "d3+" or "y3+" - just
read the relative line number of the line you want to reach - no
counting, and no need to subtract one. Ah, it's the same with "3j" -
works the same as "3+", I see.

Erik

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: plugin for toggeling line numbers

trialero
On Sun, Apr 07, 2019 at 10:40:44PM +1000, Erik Christiansen wrote:

>
> No experience with plugins, but just this in .vimrc does it for me:
>
> noremap <F1> :call Rnu_toggle()<CR>        " Toggle relative line numbering.
> "
> " Toggle relative line numbering.
> function! Rnu_toggle()
>     if &rnu == 1
>      set nornu
>   else
>      set rnu
>   endif
> endfun

hmm, this looks like an even better solution! I don't know of any speed
differences between a function in .vimrc and a plugin, but I somehow
prefer less extra frills.

I'll try this one, Erik -- TNX

//meine

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: plugin for toggeling line numbers

trialero
In reply to this post by Erik Christiansen
On Sun, Apr 07, 2019 at 10:40:44PM +1000, Erik Christiansen wrote:

> On 07.04.19 13:51, meine wrote:
> > I found a site where a vim plugin was used for relative line numbering
> > and I want to give it a try. relative line numbers make it easier to
> > navigate in normal mode by just using `3j' instead of `256G'. the less
> > keystrokes the better!
>
> No experience with plugins, but just this in .vimrc does it for me:
>
> noremap <F1> :call Rnu_toggle()<CR>        " Toggle relative line numbering.
> "
> " Toggle relative line numbering.
> function! Rnu_toggle()
>     if &rnu == 1
>      set nornu
>   else
>      set rnu
>   endif
> endfun

This function works like a charm!

I also found andother solution in `Mastering Vim Quickly',  p. 118 to
have relative numbers in Normal mode and absolute numbers in Insert.

Add to your .vimrc

    set number
    set relativenumber

    augroup toggle_relative_number
    autocmd InsertEnter * :setlocal norelativenumber
    autocmd InsertLeave * :setlocal relativenumber

This way you only use functions that are already aboard in default
Vim...

//meine

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: plugin for toggeling line numbers

Paul-7
In reply to this post by trialero
On Sun, Apr 07, 2019 at 01:51:55PM +0200, meine wrote:
>I found a site where a vim plugin was used for relative line numbering
>and I want to give it a try. relative line numbers make it easier to
>navigate in normal mode by just using `3j' instead of `256G'. the less
>keystrokes the better!
>
>vimawsome.com has two variants: `numbers.vim' and `vim-numbertoggle'.
>
...
>
>does anybody have experience with both of them? I'd be curious on your
>opinions! maybe there is a third one that is niftier, I'd like to know.

I have number and relativenumber set by default, and I use Pope's vim-unimpaired (https://github.com/tpope/vim-unimpaired) for handy toggling of common settings, including these.

I also use these autocmds:

" relativenumber only in current window
autocmd BufEnter,WinEnter,InsertLeave *
\ if &filetype !=# 'help' | setlocal relativenumber | endif
autocmd BufLeave,WinLeave,InsertEnter *
\ if &filetype !=# 'help' | setlocal norelativenumber | endif

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.

signature.asc (817 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: plugin for toggeling line numbers

trialero
> >vimawsome.com has two variants: `numbers.vim' and `vim-numbertoggle'.
>
> I have number and relativenumber set by default, and I use Pope's vim-unimpaired (https://github.com/tpope/vim-unimpaired) for handy toggling of common settings, including these.

Thanks @Paul for your suggestions and code!

using the one and the other to find out my preferred solution, I noticed
that goyo.vim and switching relative (or better 'hybrid') numbers can cause cluttered output on the screen.

see eg. https://github.com/junegunn/goyo.vim/issues/42 and other issues.

a regular console makes quite a mess in goyo, putting text on the empty
parts of the screen to the left and right, making navigation and knowing
where the cursor is problematic;

the same is in xterm in a GUI environment

in gvim the output is clean

probably I'll have to make settings more specific to the environments I
use, found some remarks of the maker of goyo on using GoyoEnter and
GoyoLeave with `set: <no/plain/relative line numbers> in .vimrc

I'll just have to find out, preferrably for the console and xterm, as
gvim is not my favourite vim-way.

open for suggestions...

//meine

--
--
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 [hidden email].
For more options, visit https://groups.google.com/d/optout.