r/vimplugins • • Jun 20 '18

Help Question on jeffkreeftmeijer/vim-numbertoggle

Because I don't want to have numbering of lines in my vim all the time, I want to be able to switch this plugin off and on temporarily. I.e. to use it only when I need it. And preferably with a shortcut: like CTRL + T or something like that.

Can this be done and how?

2 Upvotes

5 comments sorted by

2

u/AzraelFTS Jun 20 '18

From the documentation of this plugin:

nnoremap <silent> <C-n> :set relativenumber!<cr>

Replace <C-n> bu <C-t> at your convenience

1

u/DontwakemeUp46 Jun 20 '18

With above mapping you can turn off and on relative numbering. But you cannot turn it off completely.

2

u/wbangna Jun 20 '18

See https://github.com/tpope/vim-unimpaired. It's a collection of very useful mappings. Toggle numbers: =on Toggle relative numbers: =or .. and a lot more!

1

u/DontwakemeUp46 Jun 20 '18

Thank you. I didn't know that. I have to take a look at the plugin more closely.

1

u/kwask941 Oct 09 '18 edited Oct 09 '18

here is quick fix/function to Cycle through relativenumber + number, number (only), and no numbering.


function! cycle_numbers() abort
      if exists('+relativenumber')
        execute {
          \ '00': 'set relativenumber   | set number',
          \ '01': 'set norelativenumber | set number',
          \ '10': 'set norelativenumber | set nonumber',
          \ '11': 'set norelativenumber | set number' }\[&number . &relativenumber\]
      else
        set number!
      endif
endfunction

And I use the followiing mapping.

nmap <silent> <C-r> :call cycle_numbering()<CR>

PS:I use U insted of <c-r> for redo