Open qleguennec opened 5 years ago
I suspect that that's kind of impossible to get around, given that the underlying vterm and the shell connected to it are responsible for updates. You might want to try using a shell that supports vi bindings... but it might be tricky to integrate in a satisfying way with evil (you end up having to juggle both the shell's normal mode and evil's normal state).
Is it possible to set up a mechanism whereby lines of text can be inserted into the buffer, and have vterm send each such line to the underlying shell for processing?
I'm thinking we could set up some kind of function whereby the current line is yanked into a temporary buffer or something, and normal emacs / evil text editing can be done, and on close, the contents of that buffer are pasted into the vterm buffer to be processed by the shell as a series of command lines. Would that be possible?
This would also enable the use of vterm snippets with something like yasnippet, which would (i think) be very useful (especially if you have commands you use often that you want to be able to insert into ssh sessions, for example)
Could vterm-send-string
be used for this? The following function
(defun test-vterm-insert-string ()
(interactive)
(vterm-send-string (read-from-minibuffer "What do you want do send? ")))
inserts a command in the current vterm buffer. If you want to be immediately executed you can add vterm-send-return
:
(defun test-vterm-insert-string ()
(interactive)
(vterm-send-string (read-from-minibuffer "What do you want do send? "))
(vterm-send-return))
I suppose one could easily generalize this to:
Is this what you are looking for?
Note: for those who bind C-h
to delete-backward-char
(or to something equivalent), this will be handy:
(use-package vterm
:bind
(:map vterm-mode-map
([remap delete-backward-char] . vterm-send-C-h)))
It might make sense to do something like this on lower level in vterm.
Is it possible to set up a mechanism whereby lines of text can be inserted into the buffer, and have vterm send each such line to the underlying shell for processing?
I'm thinking we could set up some kind of function whereby the current line is yanked into a temporary buffer or something, and normal emacs / evil text editing can be done, and on close, the contents of that buffer are pasted into the vterm buffer to be processed by the shell as a series of command lines. Would that be possible?
I implemented a rudimentary version of this here.
Ideally there would be an option to do this directly in the vterm buffer. Nothing would be sent until you hit RET
or whatever keybinding.
This is probably intended behavior, but when I switch in evil normal mode, I am unable to use evil editing commands. Example with
cw
for deleting the current word: (apply: Buffer is read-only: #<buffer *vterm-dedicated*>
)