From 03346753771a7869bb3085c2d9056852506049de Mon Sep 17 00:00:00 2001 From: Matthias Vogelgesang Date: Sat, 10 Aug 2013 10:14:35 +0200 Subject: [PATCH] Move {count} lines in normal mode --- plugin/move.vim | 30 ++++++++++++++++++++++++------ 1 file changed, 24 insertions(+), 6 deletions(-) diff --git a/plugin/move.vim b/plugin/move.vim index 4cfd2d7..60cf83e 100644 --- a/plugin/move.vim +++ b/plugin/move.vim @@ -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 MoveBlockDown :call MoveBlockDown()