I'm trying to make a keyboard binding in Neovim that would send a selected block to the opened Neovim terminal. I've used these answers as guidelines https://vi.stackexchange.com/a/3390/3405 https://stackoverflow.com/a/6271254/859391
Though when i'm trying to call the command with a Visual Line selected I keep getting the No Range Allowed error. Am I missing something obvious?
function! s:get_visual_selection() " Why is this not a built-in Vim script function?! let [lnum1, col1] = getpos("'<")[1:2] let [lnum2, col2] = getpos("'>")[1:2] let lines = getline(lnum1, lnum2) let lines[-1] = lines[-1][: col2 - (&selection == 'inclusive' ? 1 : 2)] let lines = lines[col1 - 1:] return join(lines, "\n") endfunction augroup Terminal au! au TermOpen * let g:last_terminal_job_id = b:terminal_job_id augroup END function! REPLSend(lines) call jobsend(g:last_terminal_job_id, lines) call jobsend(g:last_terminal_job_id, "\r") " needed for the way REPL handles the input endfunction command! REPLSendLine call REPLSend([s:get_visual_selection()]) vnoremap <silent> <leader>l :REPLSendLine<cr> " leader is <Space>