diff --git a/plugin/vim-tmux-runner.vim b/plugin/vim-tmux-runner.vim index 145610c..9805d36 100644 --- a/plugin/vim-tmux-runner.vim +++ b/plugin/vim-tmux-runner.vim @@ -372,26 +372,8 @@ function! s:EnsureRunnerPane(...) endif endfunction -" From http://stackoverflow.com/q/1533565/ -" 'how-to-get-visually-selected-text-in-vimscript' -function! s:GetVisualSelection() - normal! gv - let [lnum1, col1] = getpos("'<")[1:2] - let [lnum2, col2] = getpos("'>")[1:2] - let lines = getline(lnum1, lnum2) - let lines[-1] = lines[-1][: col2 - 2] - let lines[0] = lines[0][col1 - 1:] - return lines -endfunction - -function! s:SendLineToRunner() - let line = [getline('.')] - call s:SendTextToRunner(line) -endfunction - -function! s:SendSelectedToRunner() - let lines = s:GetVisualSelection() - call s:SendTextToRunner(lines) +function! s:SendLinesToRunner() range + call s:SendTextToRunner(getline(a:firstline, a:lastline)) endfunction function! s:PrepareLines(lines) @@ -431,8 +413,7 @@ function! s:DefineCommands() command! -nargs=? VtrSendCommandToRunner call s:SendCommandToRunner() command! -nargs=? VtrResizeRunner call s:ResizeRunnerPane() command! -nargs=? VtrOpenRunner call s:EnsureRunnerPane() - command! VtrSendSelectedToRunner call s:SendSelectedToRunner() - command! VtrSendLineToRunner call s:SendLineToRunner() + command! -range VtrSendLinesToRunner ,call s:SendLinesToRunner() command! VtrKillRunner call s:KillRunnerPane() command! VtrFocusRunner call s:FocusRunnerPane() command! VtrReorientRunner call s:ReorientRunner() @@ -451,8 +432,8 @@ function! s:DefineKeymaps() nnoremap rr :VtrResizeRunner nnoremap ror :VtrReorientRunner nnoremap sc :VtrSendCommandToRunner - nnoremap sl :VtrSendLineToRunner - nnoremap sv :VtrSendSelectedToRunner + nnoremap sl :VtrSendLinesToRunner + vnoremap sl :VtrSendLinesToRunner nnoremap or :VtrOpenRunner nnoremap kr :VtrKillRunner nnoremap fr :VtrFocusRunner