When using multi-term to run a terminal within emacs, I would like to be able to paste a command into the multi-term window, and then run it. Currently, when I do so, the pasted item does appear in the multi-term input window, however, if I hit enter, the command is ignored. It also doesn't show up in the terminal's history. For example, I'm pasting
echo "hello"
It looks like it worked--I see the text following the prompt. But when I hit enter it doesn't execute. I'm using multi-term: http://www.emacswiki.org/emacs/MultiTerm
In a GUI version of Emacs, click the Edit menu (or hit F10 if it's not visible), then move the mouse over “Paste from Kill Menu”, and you will see many of the recent entries. You can click on one to paste it. In a text-only version of Emacs, you achieve the same thing by navigating with keys instead of a mouse.
If you would only like to copy the selected region, this can be done by hitting Alt + w. To cut, or kill, the text, you can use the keys Ctrl + k to kill a particular line, or the Ctrl + w command to kill the entire selected region. To paste, or yank, the text, press the keys Ctrl + y.
The default function yank
doesn't work with multi-term
or more
precisely with term-mode
because the yank isn't « really » inserted.
To paste, you've to use the function term-paste
which is bound to
S-insert by default. Of course, you can bind C-y
to use it in term-mode
(add-hook 'term-mode-hook (lambda ()
(define-key term-raw-map (kbd "C-y") 'term-paste)))
In term-mode (which multi-term uses) there are two input modes:
You can switch to line mode with C-cC-j then yank the text, switch back to char mode C-cC-k and run the command. I think of char-mode as the input mode that works like you would expect terminal input to work. For example, if you type something on the command line and cut it with C-x, then C-y will paste what you cut from the command line. I think of line-mode as the input mode that you would expect from a text buffer in emacs.
For details about the two input modes check this page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With