diff options
author | tdro <tdro@users.noreply.github.com> | 2020-07-02 22:57:25 -0400 |
---|---|---|
committer | tdro <tdro@users.noreply.github.com> | 2020-07-02 22:57:25 -0400 |
commit | 6e0437fb272d59873ba784ca852c84b90d5946fb (patch) | |
tree | 294c24807f598a35ac6732203a50e005f7e4bdac /.vimrc | |
parent | 3679ae25daf1fa61cb42c29b830b81a566737f82 (diff) | |
download | dotfiles-6e0437fb272d59873ba784ca852c84b90d5946fb.tar.gz dotfiles-6e0437fb272d59873ba784ca852c84b90d5946fb.tar.bz2 dotfiles-6e0437fb272d59873ba784ca852c84b90d5946fb.zip |
.vimrc: Add experimental repl command
Diffstat (limited to '.vimrc')
-rw-r--r-- | .vimrc | 19 |
1 files changed, 19 insertions, 0 deletions
@@ -255,6 +255,25 @@ let g:nnn#set_default_mappings = 0 " Disable default mappings let g:nnn#layout = 'new' " Opens the nnn window in a split let g:nnn#layout = { 'left': '~20%' } " Left 20% of the window +" Send command to terminal https://vi.stackexchange.com/questions/14300/vim-how-to-send-entire-line-to-a-buffer-of-type-terminal +function s:repl(start, end) + let g:terminal_buffer = get(g:, 'terminal_buffer', -1) + if g:terminal_buffer == -1 || !bufexists(g:terminal_buffer) + terminal + let g:terminal_buffer = bufnr('') + wincmd p + elseif bufwinnr(g:terminal_buffer) == -1 + exec 'sbuffer ' . g:terminal_buffer + wincmd p + endif + call term_sendkeys(g:terminal_buffer, join(getline(a:start, a:end), "\<cr>") . "\<cr>") +endfunction + +command! -range Repl call s:repl(<line1>, <line2>) + +nnoremap <leader>cc :Repl<cr> +vnoremap <leader>cc :Repl<cr> + "----------------Autorun----------------" |