I've the following function and accompanying key-bindings to send texts from vim in one tmux pane to other:
" copy yanked text to tmux pane
function! Send_to_tmux(count) abort
let _count = (a:count == 0) ? 2 : a:count
let text = @z
let text = substitute(text, ';', '\\;', 'g')
let text = substitute(text, '"', '\\"', 'g')
let text = substitute(text, '\n', '" Enter "', 'g')
let text = substitute(text, '!', '\\!', 'g')
let text = substitute(text, '%', '\\%', 'g')
let text = substitute(text, '#', '\\#', 'g')
silent execute "!tmux send-keys -t " . _count . " \"" . text . "\""
silent execute "!tmux send-keys -t " . _count . "Enter"
unlet _count
unlet text
endfunction
nnoremap <expr> <Leader>p '"zyip:call Send_to_tmux('.v:count.')<CR>'
xnoremap <expr> <Leader>p '"zy:call Send_to_tmux('.v:count.')<CR>'
I basically use this function when I use SQL. Now, SQL has commenting structure of two types:
(written in the structure of :h 'commentstring'
)
- /* %s */
- -- %s
I always used the first type of comment, and didn't set up the substitute command for second type of comment. And now I see that I can't send texts into other tmux panes of structure -- texts
. I have tried it in bare bash, and MySQL command line, same result. So, I guess bash is not taking string of that structure, or tmux is eating it itself.
I've removed all tmux configurations and tried to do it, same result. So, I don't think it's a problem with my tmux config.
How do I send --
to tmux panes from vim?