← Back to Upcase

Range Commands With Relative Numbering (Jason Draper)


(Upcase ) #1
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

(Thom Obarski) #2

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

Basic Commands:

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

(Aaron Mc Adam) #5

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!


(Tim Habermaas) #6

Add

set relativenumber
set number

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


(David Becerra) #7

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.


(Aaron Mc Adam) #8

Ah cool, thanks guys!


(Geoff Harcourt) #9

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