USE AT YOUR OWN RISK
IMPORTANT: you are now required to call setup()
!
Send lines from your code buffer to a terminal buffer.
- Open a terminal buffer.
- Set up the terminal such that you just have to start typing the lines you want to insert - this means if you use vi-mode make sure you are in insert-mode!
- If you have several terminal buffers loaded: From your code buffer
run
:SendlineConnect <term-bufnr>
to set the intended target. - Send current line - or multiple lines by visually selecting (at least
parts of) them - with
:Sendline
. Actually you can send any range of lines by specifying it with the usual notation, however, motions or repeats do not work.
Tries to send current line or all lines with visual selection to the terminal with
- bufnr (and sets it as the buffer's new connection)
- or the connected terminal if no bufnr given to
:Sendline
(removes the connection if it is invalid) - or tries to autoconnect.
Like :[range]Sendline
but does not save new / override old
connection.
Set the target terminal for the current buffer. It will be used when
:Sendline
is called without an explicit target.
Removes the given or current buffer's connection.
To activate the plugin call the setup function with your desired overrides. Here this is shown with the default settings:
require('sendline').setup({
---When set, calling :Sendline or :SendlineConnect without a target
---buffer automatically connects to a terminal if there is no
---saved connection and there is exactly 1 valid target terminal.
autoconnect = true,
---If this is not set a terminal may not connect to itself, thus
---2 terminals can autoconnect to each other.
allow_connect_to_self = false,
---If this is set, closing a terminal removes all saved connections
---to this terminal.
autodisconnect = true,
---If this is set you are asked for confirmation when sending from a
---terminal. This is supposed to prevent accidentally sending
---potentially very destructive commands to a terminal.
confirm_send_from_terminal = true,
})
- Send current line and advance
:nnoremap <cr> <cmd>Sendline<cr>+
- Send unindented selection
vnoremap <cr> 100<gv:Sendline<cr>u
Unindent the lines before you send them (see: Tips>Keymaps for a helpful map to do so).
- Ipython: you can just use the
--no-autoindent
flag
This is intended. I understand that this might be useful sometimes, but considering I'd have to handle all the different selection modes I decided to not implement this and rely on the simple tools at hand (user-commands and ranges).
Indeed, this is intended, because this plugin is made for executing lines in a repl running in a neovim terminal.
Include n trailing, empty lines in the lines you send or, after sending the code lines, send an empty line n times. If you use a mapping this shouldn't be a big deal.
This could have happened because you used a mapping which uses
<cmd>Sendline
. Use :
instead of <cmd>
to capture your selected
range.
The neovim cursor position of the terminal window has to be at the last
line of the terminal buffer. Navigate there with G
in normal mode.
The confirmation dialog receives all characters after the <CR> in your
mapping (for example this :Sendline<CR>+
would send "+" to the
confirmation dialog). To avoid this use a different mapping in terminal
buffers.