Range Commands With Relative Numbering (Jason Draper)

Jason Draper helps you streamline by using range commands with relative numbering. Basic Commands: * :7y * :-1,-3d * :-1,-3t.
This is a companion discussion topic for the original entry at https://thoughtbot.com/upcase/videos/range-commands-with-relative-numbering-jason-draper
1 Like

Jason Draper helps you streamline by using range commands with relative numbering.

Basic Commands:

  • :7y
  • :-1,-3d
  • :-1,-3t.

How did Jason get the actual line number to show on the current line when in relative number mode, rather than just 0? Looks useful!

Add

set relativenumber
set number

to your .vimrc to get relative line numbers and the current line number.

1 Like

I have this in my .vimrc file to toggle between the two:

function! NumberToggle()
  if(&relativenumber ==1)
    set norelativenumber
    set number
  else
    set relativenumber
    set number
  endif
endfunction

nnoremap <leader>n :call NumberToggle()<cr>

It works alright.

1 Like

Ah cool, thanks guys!

@DavidVII, if you have vim-unimpaired, you can also use the plugins toggles, con for toggling numbering and cor to toggle relative number.

1 Like