Created
October 29, 2013 10:02
-
-
Save kossnocorp/7211844 to your computer and use it in GitHub Desktop.
Copy of http://www.vim.org/scripts/script.php?script_id=4754. I needed it because https://github.com/vim-scripts/mlessnau_block_shift is not created yet.
This file contains hidden or 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
let s:calls_for_block = 0 | |
function! BlockShiftGuard(size) | |
let s:calls_for_block = s:calls_for_block + 1 | |
if s:calls_for_block < a:size | |
return 0 | |
endif | |
let s:calls_for_block = 0 | |
return 1 | |
endfunction | |
function! BlockShiftUp() | |
let l:size = a:lastline - a:firstline + 1 | |
if !BlockShiftGuard(l:size) | |
return | |
endif | |
call cursor(a:firstline, 0) | |
execute 'normal! ' . l:size . 'dd' | |
if 1 < a:firstline | |
call cursor(a:firstline - 1, 0) | |
endif | |
execute 'normal! P' | |
if 1 < l:size | |
execute 'normal! V' . (l:size - 1) . 'j' | |
else | |
execute 'normal! V' | |
endif | |
endfunction | |
function! BlockShiftDown() | |
let l:size = a:lastline - a:firstline + 1 | |
if !BlockShiftGuard(l:size) | |
return | |
endif | |
call cursor(a:firstline, 0) | |
execute 'normal! ' . l:size . 'dd' | |
execute 'normal! p' | |
if 1 < l:size | |
execute 'normal! V' . (l:size - 1) . 'j' | |
else | |
execute 'normal! V' | |
endif | |
endfunction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment