Skip to content

Commit

Permalink
Add option to always send a trailing newline
Browse files Browse the repository at this point in the history
  • Loading branch information
pbackus committed Feb 28, 2019
1 parent dc79a29 commit d8939d2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions doc/tslime.txt
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,11 @@ targets easier:
*g:tslime_always_current_window*
When selecting a target, always choose the current
tmux window without prompting.

*g:tslime_ensure_newline*
When sending text selected by a |characterwise| motion or text object, the
trailing newline may be omitted. This can cause problems when sending text to
a shell or REPL that expects a trailing newline after each command. To ensure
a trailing newline is always sent, add the following line to your vimrc: >

let g:tslime_ensure_newline = 1
4 changes: 3 additions & 1 deletion plugin/tslime.vim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function! Send_to_Tmux(text)
call <SID>Tmux_Vars()
endif

call system("tmux load-buffer -b tslime -", a:text)
let add_newline = exists("g:tslime_ensure_newline") && (a:text[-1:] != "\n")

call system("tmux load-buffer -b tslime -", a:text . (add_newline ? "\n" : ""))
call system("tmux paste-buffer -d -b tslime -t " . s:tmux_target())
endfunction

Expand Down

0 comments on commit d8939d2

Please sign in to comment.