Skip to content

Commit

Permalink
Move {count} lines in normal mode
Browse files Browse the repository at this point in the history
  • Loading branch information
matze committed Aug 10, 2013
1 parent 8f58d3b commit 0334675
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions plugin/move.vim
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,36 @@ function! s:MoveBlockUp() range
call s:ResetCursor()
endfunction

function! s:MoveLineUp()
if line('.') == line('0')
function! s:MoveLineUp() range
let distance = 2

if v:count > 0
let distance = distance + v:count - 1
endif

if (line('.') - distance) < 0
execute 'm 0'
return
endif
execute 'm-2'

execute 'm-' . distance
endfunction

function! s:MoveLineDown()
if line('.') == line('0')
function! s:MoveLineDown() range
let distance = 1

if v:count > 0
let distance = distance + v:count - 1
endif

echom distance

if (line('.') + distance) > line('$')
execute 'm $'
return
endif
execute 'm+1'

execute 'm+' . distance
endfunction

vnoremap <silent> <Plug>MoveBlockDown :call <SID>MoveBlockDown()<CR>
Expand Down

0 comments on commit 0334675

Please sign in to comment.