Skip to content

Instantly share code, notes, and snippets.

@tacahiroy
Created September 26, 2012 14:23
Show Gist options
  • Select an option

  • Save tacahiroy/3788349 to your computer and use it in GitHub Desktop.

Select an option

Save tacahiroy/3788349 to your computer and use it in GitHub Desktop.
move up/down visualed lines
function! s:move_block(d) range
let cnt = a:lastline - a:firstline
if a:d ==# 'u'
let sign = '-'
let cnt = 2
else
let sign = '+'
let cnt += 1
endif
execute printf('%d,%dmove%s%d', a:firstline, a:lastline, sign, cnt)
endfunction
vnoremap <Down> :call <SID>move_block('d')<Cr>==gv
vnoremap <Up> :call <SID>move_block('u')<Cr>==gv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment