call minpac#init()
" ...
" more plugins
" ...
call minpac#add('habamax/vim-sendtoterm')
Then :call minpac#update()
to install it.
-
open terminal
:term
-
type in any other buffer:
dir /w
-
<leader>tt
to send current line -
You should see directory list printed in a terminal
-
open terminal
:term
-
run interactive elixir there
iex
-
in the other buffer type
(1..100) |> Enum.sum()
-
<leader>tt
to send current line toiex
-
You should see something like:
Interactive Elixir (1.8.1) - press Ctrl+C to exit (type h() ENTER for help) iex(1)> (1..100) |> Enum.sum() 5050 iex(2)>
You can also use other text objects:
defmodule MyMod do
def hello(world) do
IO.puts(world)
end
end
MyMod.hello("Hey!")
Press <leader>tip
to send current paragraph to iex
:
iex(2)> defmodule MyMod do
def hello(world) do
...(2)> IO.puts(world)
...(2)> end
end
...(2)> MyMod.hello("Hey!")
...(2)> {:module, MyMod,
<<70, 79, 82, 49, 0, 0, 4, 88, 66, 69, 65, 77, 65, 116, 85, 56, 0, 0, 0, 140,
0, 0, 0, 15, 12, 69, 108, 105, 120, 105, 114, 46, 77, 121, 77, 111, 100, 8,
95, 95, 105, 110, 102, 111, 95, 95, 7, ...>>, {:hello, 1}}
iex(3)> Hey!
:ok
iex(4)>
To use something else instead of <leader>t
you remap <Plug>(SendToTerm)
s, for example:
xmap <leader>r <Plug>(SendToTerm)
nmap <leader>r <Plug>(SendToTerm)
omap <leader>r <Plug>(SendToTerm)
nmap <leader>rr <Plug>(SendToTermLine)
What about Ctrl-Enter
to send current line (probably would not work for all terminals)?
nmap <C-CR> <Plug>(SendToTermLine)
What if I want my cursor to go to the next non-empty line after current line was sent to terminal?
nmap <C-CR> <Plug>(SendToTermLine)j:call search('^\s*\S.*', 'W')<CR>
By default all tabs are converted to spaces and if you don’t want it:
let g:sendtoterm_expandtab = 0