I'm trying to create my own mapping with motion in Vim after reading this stackexchange question. I'm using the plugin vimtux to send code to specific tmux instances and I now want to be able to do this using motion instead of making a detour via visual mode. What I have so far in my .vimrc:
nmap <silent> <leader>c :set opfunc=SendWithMotion<CR>g@
function! SendWithMotion(type)
silent exec 'normal! `[v`]y`]'
call SendToTmux(@")
call ExecuteKeys('Enter')
endfunction
This is working great for motions like \cw
or \cap
, however if I use \cip
, the last line of the paragraph is captured only as its first character. E.g.:
abcd
abcd
abcd
results in sent code:
abcd
abcd
a
What could be the issue here? Sorry if this has some stupid solution, I'm really new to Vim! But I already love it :-)