I know in visual block mode, by <S-i> (I) one can insert in multiple selected lines, however I want to achieve the same effect by a function, let's say I have a functions which can tell the three sub-visual modes (visual-character, visual-line, visual-block) as follows,
function! VisualMappingSpace()
let m = visualmode()
if m ==# 'v'
echo 'character-wise visual'
elseif m == 'V'
echo 'line-wise visual'
elseif m == "\<C-V>"
echo 'block-wise visual'
endif
endfunction
I've tried as follows but it doesn't work. I want to insert soemthing to the lines I select when I hit <space> in visual-block mode.
function! VisualMappingSpace()
let m = visualmode()
if m ==# 'v'
exec "normal y"
elseif m == 'V'
exec "normal y"
elseif m == "\<C-V>"
let g:block_insert_content = input("")
exec "normal I ".g:block_insert_content
endif
endfunction
vnoremap <silent> <Space> :call VisualMappingSpace()<CR>
exec "normal y"should benormal y. Anyway, what do you expect? What do you get instead?visual-characterandvisual-linemode when I hit<space>I can copy the selected lines to the default register, and invisual-blockmode when I hit<space>I can insert something to the lines I selected, just like what I hitIinvisual-blockmode do.