Send buffer to a running terminal window in vim 8












3















Is it possible to send the contents of a buffer to a running terminal window. That window can be running e.g a REPL for python code.



I mean the new terminal feature of VIM rather than external plugins or previous versions.










share|improve this question




















  • 1





    Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

    – Peter Rincker
    Mar 16 '18 at 14:27











  • It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

    – Stagrovin
    Mar 19 '18 at 15:14
















3















Is it possible to send the contents of a buffer to a running terminal window. That window can be running e.g a REPL for python code.



I mean the new terminal feature of VIM rather than external plugins or previous versions.










share|improve this question




















  • 1





    Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

    – Peter Rincker
    Mar 16 '18 at 14:27











  • It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

    – Stagrovin
    Mar 19 '18 at 15:14














3












3








3








Is it possible to send the contents of a buffer to a running terminal window. That window can be running e.g a REPL for python code.



I mean the new terminal feature of VIM rather than external plugins or previous versions.










share|improve this question
















Is it possible to send the contents of a buffer to a running terminal window. That window can be running e.g a REPL for python code.



I mean the new terminal feature of VIM rather than external plugins or previous versions.







vim terminal






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 17 '18 at 3:41









Saveen Dhiman

2,81492434




2,81492434










asked Mar 16 '18 at 10:30









StagrovinStagrovin

373




373








  • 1





    Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

    – Peter Rincker
    Mar 16 '18 at 14:27











  • It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

    – Stagrovin
    Mar 19 '18 at 15:14














  • 1





    Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

    – Peter Rincker
    Mar 16 '18 at 14:27











  • It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

    – Stagrovin
    Mar 19 '18 at 15:14








1




1





Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

– Peter Rincker
Mar 16 '18 at 14:27





Will this terminal buffer already be running? May want to look at :h term_sendkeys(). Or will this terminal buffer be ran each time you want to send input? Simply use :terminal with a range. See :h :terminal

– Peter Rincker
Mar 16 '18 at 14:27













It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

– Stagrovin
Mar 19 '18 at 15:14





It's a running terminal. I'd like to send my whole code or selected parts of it to the running python session without closing it. I've seen the term_sendkeys function, but not sure how I can use it to send the my editing buffer to terminal.

– Stagrovin
Mar 19 '18 at 15:14












1 Answer
1






active

oldest

votes


















3














You can use term_sendkeys() to send data to a terminal buffer. However there are some considerations:




  • Need to capture data to use term_sendkeys() often this is via yanking text

  • Need to know which terminal buffer to send to


Here is some code simplify and automate the send to terminal buffer workflow. Put inside vimrc file or make a small plugin.



augroup my_terminal
autocmd!
autocmd BufWinEnter,TerminalOpen * if &buftype ==# 'terminal' |
call s:my_term(+expand('<abuf>')) |
endif
augroup END


let s:terms = {}
function! s:my_term(bufnr)
let tabpagenr = tabpagenr()
let s:terms[tabpagenr] = a:bufnr
endfunction

function! s:op(type, ...)
let [sel, rv, rt] = [&selection, @@, getregtype('"')]
let &selection = "inclusive"

if a:0
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif

call s:send_to_term(@@)

let &selection = sel
call setreg('"', rv, rt)
endfunction

function! s:send_to_term(keys)
let bufnr = get(s:terms, tabpagenr(), 0)
if bufnr > 0 && bufexists(bufnr)
let keys = substitute(a:keys, 'n$', '', '')
call term_sendkeys(bufnr, keys . "<cr>")
echo "Sent " . len(keys) . " chars -> " . bufname(bufnr)
else
echom "Error: No terminal"
endif
endfunction

command! -range -bar SendToTerm call s:send_to_term(join(getline(<line1>, <line2>), "n"))
nmap <script> <Plug>(send-to-term-line) :<c-u>SendToTerm<cr>
nmap <script> <Plug>(send-to-term) :<c-u>set opfunc=<SID>op<cr>g@
xmap <script> <Plug>(send-to-term) :<c-u>call <SID>op(visualmode(), 1)<cr>


You can make setup your own mappings. Example:



nmap yrr <Plug>(send-to-term-line)
nmap yr <Plug>(send-to-term)
xmap R <Plug>(send-to-term)


You can now use :[range]SendToTerm to send a [range] of lines to the last used terminal buffer in a tab-page. You can also use crr to send a line, cr{motion} to send a {motion} text, or use <leader>r to send visually selected text to the terminal buffer. Note: You must have a terminal buffer opened beforehand in the current tab-page.






share|improve this answer


























  • Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

    – simlei
    May 10 '18 at 10:11













  • @simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

    – Peter Rincker
    May 10 '18 at 21:00






  • 1





    An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

    – Rastapopoulos
    Aug 22 '18 at 9:51











  • And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

    – Rastapopoulos
    Aug 22 '18 at 9:56






  • 1





    @Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

    – Peter Rincker
    Nov 19 '18 at 17:02











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49318522%2fsend-buffer-to-a-running-terminal-window-in-vim-8%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









3














You can use term_sendkeys() to send data to a terminal buffer. However there are some considerations:




  • Need to capture data to use term_sendkeys() often this is via yanking text

  • Need to know which terminal buffer to send to


Here is some code simplify and automate the send to terminal buffer workflow. Put inside vimrc file or make a small plugin.



augroup my_terminal
autocmd!
autocmd BufWinEnter,TerminalOpen * if &buftype ==# 'terminal' |
call s:my_term(+expand('<abuf>')) |
endif
augroup END


let s:terms = {}
function! s:my_term(bufnr)
let tabpagenr = tabpagenr()
let s:terms[tabpagenr] = a:bufnr
endfunction

function! s:op(type, ...)
let [sel, rv, rt] = [&selection, @@, getregtype('"')]
let &selection = "inclusive"

if a:0
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif

call s:send_to_term(@@)

let &selection = sel
call setreg('"', rv, rt)
endfunction

function! s:send_to_term(keys)
let bufnr = get(s:terms, tabpagenr(), 0)
if bufnr > 0 && bufexists(bufnr)
let keys = substitute(a:keys, 'n$', '', '')
call term_sendkeys(bufnr, keys . "<cr>")
echo "Sent " . len(keys) . " chars -> " . bufname(bufnr)
else
echom "Error: No terminal"
endif
endfunction

command! -range -bar SendToTerm call s:send_to_term(join(getline(<line1>, <line2>), "n"))
nmap <script> <Plug>(send-to-term-line) :<c-u>SendToTerm<cr>
nmap <script> <Plug>(send-to-term) :<c-u>set opfunc=<SID>op<cr>g@
xmap <script> <Plug>(send-to-term) :<c-u>call <SID>op(visualmode(), 1)<cr>


You can make setup your own mappings. Example:



nmap yrr <Plug>(send-to-term-line)
nmap yr <Plug>(send-to-term)
xmap R <Plug>(send-to-term)


You can now use :[range]SendToTerm to send a [range] of lines to the last used terminal buffer in a tab-page. You can also use crr to send a line, cr{motion} to send a {motion} text, or use <leader>r to send visually selected text to the terminal buffer. Note: You must have a terminal buffer opened beforehand in the current tab-page.






share|improve this answer


























  • Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

    – simlei
    May 10 '18 at 10:11













  • @simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

    – Peter Rincker
    May 10 '18 at 21:00






  • 1





    An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

    – Rastapopoulos
    Aug 22 '18 at 9:51











  • And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

    – Rastapopoulos
    Aug 22 '18 at 9:56






  • 1





    @Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

    – Peter Rincker
    Nov 19 '18 at 17:02
















3














You can use term_sendkeys() to send data to a terminal buffer. However there are some considerations:




  • Need to capture data to use term_sendkeys() often this is via yanking text

  • Need to know which terminal buffer to send to


Here is some code simplify and automate the send to terminal buffer workflow. Put inside vimrc file or make a small plugin.



augroup my_terminal
autocmd!
autocmd BufWinEnter,TerminalOpen * if &buftype ==# 'terminal' |
call s:my_term(+expand('<abuf>')) |
endif
augroup END


let s:terms = {}
function! s:my_term(bufnr)
let tabpagenr = tabpagenr()
let s:terms[tabpagenr] = a:bufnr
endfunction

function! s:op(type, ...)
let [sel, rv, rt] = [&selection, @@, getregtype('"')]
let &selection = "inclusive"

if a:0
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif

call s:send_to_term(@@)

let &selection = sel
call setreg('"', rv, rt)
endfunction

function! s:send_to_term(keys)
let bufnr = get(s:terms, tabpagenr(), 0)
if bufnr > 0 && bufexists(bufnr)
let keys = substitute(a:keys, 'n$', '', '')
call term_sendkeys(bufnr, keys . "<cr>")
echo "Sent " . len(keys) . " chars -> " . bufname(bufnr)
else
echom "Error: No terminal"
endif
endfunction

command! -range -bar SendToTerm call s:send_to_term(join(getline(<line1>, <line2>), "n"))
nmap <script> <Plug>(send-to-term-line) :<c-u>SendToTerm<cr>
nmap <script> <Plug>(send-to-term) :<c-u>set opfunc=<SID>op<cr>g@
xmap <script> <Plug>(send-to-term) :<c-u>call <SID>op(visualmode(), 1)<cr>


You can make setup your own mappings. Example:



nmap yrr <Plug>(send-to-term-line)
nmap yr <Plug>(send-to-term)
xmap R <Plug>(send-to-term)


You can now use :[range]SendToTerm to send a [range] of lines to the last used terminal buffer in a tab-page. You can also use crr to send a line, cr{motion} to send a {motion} text, or use <leader>r to send visually selected text to the terminal buffer. Note: You must have a terminal buffer opened beforehand in the current tab-page.






share|improve this answer


























  • Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

    – simlei
    May 10 '18 at 10:11













  • @simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

    – Peter Rincker
    May 10 '18 at 21:00






  • 1





    An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

    – Rastapopoulos
    Aug 22 '18 at 9:51











  • And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

    – Rastapopoulos
    Aug 22 '18 at 9:56






  • 1





    @Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

    – Peter Rincker
    Nov 19 '18 at 17:02














3












3








3







You can use term_sendkeys() to send data to a terminal buffer. However there are some considerations:




  • Need to capture data to use term_sendkeys() often this is via yanking text

  • Need to know which terminal buffer to send to


Here is some code simplify and automate the send to terminal buffer workflow. Put inside vimrc file or make a small plugin.



augroup my_terminal
autocmd!
autocmd BufWinEnter,TerminalOpen * if &buftype ==# 'terminal' |
call s:my_term(+expand('<abuf>')) |
endif
augroup END


let s:terms = {}
function! s:my_term(bufnr)
let tabpagenr = tabpagenr()
let s:terms[tabpagenr] = a:bufnr
endfunction

function! s:op(type, ...)
let [sel, rv, rt] = [&selection, @@, getregtype('"')]
let &selection = "inclusive"

if a:0
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif

call s:send_to_term(@@)

let &selection = sel
call setreg('"', rv, rt)
endfunction

function! s:send_to_term(keys)
let bufnr = get(s:terms, tabpagenr(), 0)
if bufnr > 0 && bufexists(bufnr)
let keys = substitute(a:keys, 'n$', '', '')
call term_sendkeys(bufnr, keys . "<cr>")
echo "Sent " . len(keys) . " chars -> " . bufname(bufnr)
else
echom "Error: No terminal"
endif
endfunction

command! -range -bar SendToTerm call s:send_to_term(join(getline(<line1>, <line2>), "n"))
nmap <script> <Plug>(send-to-term-line) :<c-u>SendToTerm<cr>
nmap <script> <Plug>(send-to-term) :<c-u>set opfunc=<SID>op<cr>g@
xmap <script> <Plug>(send-to-term) :<c-u>call <SID>op(visualmode(), 1)<cr>


You can make setup your own mappings. Example:



nmap yrr <Plug>(send-to-term-line)
nmap yr <Plug>(send-to-term)
xmap R <Plug>(send-to-term)


You can now use :[range]SendToTerm to send a [range] of lines to the last used terminal buffer in a tab-page. You can also use crr to send a line, cr{motion} to send a {motion} text, or use <leader>r to send visually selected text to the terminal buffer. Note: You must have a terminal buffer opened beforehand in the current tab-page.






share|improve this answer















You can use term_sendkeys() to send data to a terminal buffer. However there are some considerations:




  • Need to capture data to use term_sendkeys() often this is via yanking text

  • Need to know which terminal buffer to send to


Here is some code simplify and automate the send to terminal buffer workflow. Put inside vimrc file or make a small plugin.



augroup my_terminal
autocmd!
autocmd BufWinEnter,TerminalOpen * if &buftype ==# 'terminal' |
call s:my_term(+expand('<abuf>')) |
endif
augroup END


let s:terms = {}
function! s:my_term(bufnr)
let tabpagenr = tabpagenr()
let s:terms[tabpagenr] = a:bufnr
endfunction

function! s:op(type, ...)
let [sel, rv, rt] = [&selection, @@, getregtype('"')]
let &selection = "inclusive"

if a:0
silent exe "normal! `<" . a:type . "`>y"
elseif a:type == 'line'
silent exe "normal! '[V']y"
elseif a:type == 'block'
silent exe "normal! `[<C-V>`]y"
else
silent exe "normal! `[v`]y"
endif

call s:send_to_term(@@)

let &selection = sel
call setreg('"', rv, rt)
endfunction

function! s:send_to_term(keys)
let bufnr = get(s:terms, tabpagenr(), 0)
if bufnr > 0 && bufexists(bufnr)
let keys = substitute(a:keys, 'n$', '', '')
call term_sendkeys(bufnr, keys . "<cr>")
echo "Sent " . len(keys) . " chars -> " . bufname(bufnr)
else
echom "Error: No terminal"
endif
endfunction

command! -range -bar SendToTerm call s:send_to_term(join(getline(<line1>, <line2>), "n"))
nmap <script> <Plug>(send-to-term-line) :<c-u>SendToTerm<cr>
nmap <script> <Plug>(send-to-term) :<c-u>set opfunc=<SID>op<cr>g@
xmap <script> <Plug>(send-to-term) :<c-u>call <SID>op(visualmode(), 1)<cr>


You can make setup your own mappings. Example:



nmap yrr <Plug>(send-to-term-line)
nmap yr <Plug>(send-to-term)
xmap R <Plug>(send-to-term)


You can now use :[range]SendToTerm to send a [range] of lines to the last used terminal buffer in a tab-page. You can also use crr to send a line, cr{motion} to send a {motion} text, or use <leader>r to send visually selected text to the terminal buffer. Note: You must have a terminal buffer opened beforehand in the current tab-page.







share|improve this answer














share|improve this answer



share|improve this answer








edited Nov 19 '18 at 17:01

























answered Mar 19 '18 at 15:25









Peter RinckerPeter Rincker

33k65172




33k65172













  • Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

    – simlei
    May 10 '18 at 10:11













  • @simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

    – Peter Rincker
    May 10 '18 at 21:00






  • 1





    An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

    – Rastapopoulos
    Aug 22 '18 at 9:51











  • And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

    – Rastapopoulos
    Aug 22 '18 at 9:56






  • 1





    @Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

    – Peter Rincker
    Nov 19 '18 at 17:02



















  • Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

    – simlei
    May 10 '18 at 10:11













  • @simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

    – Peter Rincker
    May 10 '18 at 21:00






  • 1





    An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

    – Rastapopoulos
    Aug 22 '18 at 9:51











  • And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

    – Rastapopoulos
    Aug 22 '18 at 9:56






  • 1





    @Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

    – Peter Rincker
    Nov 19 '18 at 17:02

















Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

– simlei
May 10 '18 at 10:11







Hi, I'm very glad you shared this code! I assume it is your own creation. I myself have hacked together something like this, but of inferior quality. I'm going to integrate it into my setup - and doing so I would like to ask if you would be willing to share updated versions of that code if there were any! BTW: There is a vim plug-in pertaining to that (rather sad ^^) issue github.com/jalvesaq/vimcmdline/issues/31 which seems to do a great job sending bits of code to a tmux or terminal instance, but the case I am interested in - vim 8 :term - is unfortunately not supported.

– simlei
May 10 '18 at 10:11















@simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

– Peter Rincker
May 10 '18 at 21:00





@simlei I made this code, but do not personally use it. Feel free to use it and even roll it up into a plugin of your own if you want

– Peter Rincker
May 10 '18 at 21:00




1




1





An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

– Rastapopoulos
Aug 22 '18 at 9:51





An alternative to cr (used by vim-abolish for coerce), you can also use yr (mnemonic you run).

– Rastapopoulos
Aug 22 '18 at 9:51













And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

– Rastapopoulos
Aug 22 '18 at 9:56





And in visual mode, for consistency with vim-surround (which uses S) and vim-exchange (which uses X), I like to use R. (The default wasn't very useful.)

– Rastapopoulos
Aug 22 '18 at 9:56




1




1





@Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

– Peter Rincker
Nov 19 '18 at 17:02





@Vinz, you are correct. It seems that newer Vim's do not call BufWinEnter for terminal windows anymore. You must now use TerminalOpen autocmd. I have updated the code. Thank you

– Peter Rincker
Nov 19 '18 at 17:02




















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49318522%2fsend-buffer-to-a-running-terminal-window-in-vim-8%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Tangent Lines Diagram Along Smooth Curve

Yusuf al-Mu'taman ibn Hud

Zucchini