Skip to content

Instantly share code, notes, and snippets.

@voyeg3r
Created February 14, 2018 17:18
Show Gist options
  • Save voyeg3r/cfbcafba410259ceb7362397788dd6a4 to your computer and use it in GitHub Desktop.
Save voyeg3r/cfbcafba410259ceb7362397788dd6a4 to your computer and use it in GitHub Desktop.
" In this version, even if your paragraph does not have a preceding blank line
" it will performa the task, pleas comment on it.
function! MoveEm(position)
let saved_cursor = getpos(".")
"let previous_blank_line = search('^$', 'bn')
keepjumps execute 'normal {'
if getline('.') !~ '^$'
let previous_blank_line = line('.') - 1
else
let previous_blank_line = line('.')
endif
let target_line = previous_blank_line + a:position - 1
call setpos('.', saved_cursor)
execute 'move ' . target_line
call setpos('.', saved_cursor)
endfunction
for position in range(1, 9)
execute 'nnoremap m' . position . ' :call MoveEm(' . position . ')<cr>'
endfor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment