In bash one can edit the current commandline in $EDITOR by pressing <c-x><c-e>.I am running bash inside a terminal buffer within Neovim. I would like to be able to press <c-x><c-e> and have Neovim open a new buffer (:new), in the same Neovim instance, with the current contents of the commandline. When I close that buffer (:bdelete) I would like to have the contents of the buffer replace what was on the commandline.Is this possible?
Edit Neovim terminal commandline within the same Neovim instance
terminal;external command;neovim
I've now turned the script below into a plugin: nvim-editcommand, or if you don't mind starting you terminals with a plugin command nvim-terminus provides a few more featuresFinally got it working in pure (ugly) vimscript:     set the name of the current buffer, useful for setting the name of terminal buffersfunction! SetFileName()  execute 'file ' . input('Enter name: ')endfunction - yank from last line with prompt ('> ') to last line into register c - clear commandline - call functiontnoremap <c-x> <c-\><c-n>:execute ':?> ?,$y c'<cr>A<c-c><c-\><c-n>:call EditCommandline()<cr>function! EditCommandline()   clear search highlighting  let @/ =    - set an autocmd on the current (terminal) buffer that will run when the buffer is next entered   - put from register c (where the new command will be)   - remove the autocmd   - go to insert mode  autocmd BufEnter <buffer> put c | autocmd! BufEnter <buffer> | call feedkeys('A')   get all text after prompt '> '  let s:command = strpart(@c, strridx(@c, > ) + 2)   open new empty buffer  new    make buffer a scratch buffer  setlocal buftype=nofile  setlocal bufhidden=hide  setlocal noswapfile   put command into buffer  put! =s:command   remove extra lines  %join!   copy buffer to register when it is closed  autocmd BufLeave <buffer> :%yank cendfunction