Created
February 14, 2018 17:18
-
-
Save voyeg3r/cfbcafba410259ceb7362397788dd6a4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" 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