A tiny vim plugin that sends a word/line/paragraph of text from vim into a tmux pane for execution.
git clone https://github.com/m-col/tide
Files | Refs | Readme | License

Commit e1136b422dcce741aff8cc23e2789be9e08427ca
Parent: b5d89603192ae418629756b29efdc2852b9744bd
Author: mcol <mcol@posteo.net>
Date: 2018-12-08 23:09:06 +0000
Committer: mcol <mcol@posteo.net>
Committed: 2018-12-08 23:09:06 +0000

all functions now work as intended

plugin/tide.vim Modified

@@ -14,6 +14,7 @@
     let l:keys = substitute(l:keys, ";$", '; ', 'g') "preserve trailing semicolons
     let l:keys = substitute(l:keys, '\', '\\\\', 'g') "escape backslashes
     let l:keys = substitute(l:keys, '\"', '\\\"', 'g') "escape double quotes
+    let l:keys = substitute(l:keys, '!', '\!', 'g') "escape esclamation mark
     call system(g:tmux_cmd . "-l \"" . l:keys . "\"")
 endfunction
 function! s:TmuxSendEnter()
@@ -75,9 +76,17 @@
 
 " send visual selection
 function! s:TmuxSendVisual()
-    normal! gv"ay
-    call TmuxSendKeys(@a)
-    call s:TmuxSendEnter()
+    let [line_start, column_start] = getpos("'<")[1:2]
+    let [line_end, column_end] = getpos("'>")[1:2]
+    let lines = getline(line_start, line_end)
+    if len(lines) == 0
+	return ''
+    endif
+    let lines[-1] = lines[-1][: column_end - (&selection == 'inclusive' ? 1 : 2)]
+    let lines[0] = lines[0][column_start - 1:]
+    for line in lines
+	call TmuxSendKeysEnter(line)
+    endfor
 endfunction
 
 " command and plugin mappings
@@ -89,7 +98,7 @@
 command! -nargs=0 -complete=command TmuxSendSection call s:TmuxSendSection()
 command! -nargs=0 -complete=command -range TmuxSendLines call s:TmuxSendLines(<line1>, <line2>)
 
-xnoremap <unique> <silent> <script> <Plug>TmuxSendVisual :TmuxSendVisual<CR>
+xnoremap <unique> <silent> <script> <Plug>TmuxSendVisual :<C-u>TmuxSendVisual<CR>
 nnoremap <unique> <silent> <script> <Plug>TmuxSendParagraph :TmuxSendParagraph<CR>
 nnoremap <unique> <silent> <script> <Plug>TmuxSendLine :TmuxSendLine<CR>
 nnoremap <unique> <silent> <script> <Plug>TmuxSendWord :call TmuxSendKeysEnter(expand("<cword>"))<CR>

README.md Modified

@@ -4,13 +4,13 @@
 
 This can be used to send text from vim to tmux, in two setups:
 
-Tmux with one pane receives all text from a non-tmux vim elsewhere, or
-vim in one tmux pane can send text to the other of two panes.
+Tmux with one pane receiving all text from a non-tmuxed vim elsewhere, or
+vim in one of two tmux panes can send text to the.
 
 ## default keybindings
 
-<F9> send visual selection
-<F9> send current paragraph
+<F9> send visual selection (visual mode)
+<F9> send current paragraph (normal mode)
 <F8> send current line
 <F7> send word under cursor
 <F4> send section delimited by double comment characters