Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A vimscript function to set a visual block selection
" Inspired by @ Christian Brabandt on this question
function! SetVisualBlock(start, end)
" Trigger visual block mode
execute "norm! \<C-v>\<Esc>"
" Set the marks
call setpos("'<", [ 0, a:start[0], a:start[1] ])
call setpos("'>", [ 0, a:end[0], a:end[1] ])
" Select based on the marks
norm! gv
" Calling the function
call SetVisualBlock([24, 6], [22, 3])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.