[英]Paste a word at ansi-term on Emacs
I use ansi-term on Emacs and need to paste some words there. 我在Emacs上使用ansi-term,需要在其中粘贴一些单词。 "Paste" only works with mouse mid-button. “粘贴”仅适用于鼠标中键。 I know that with Cx Cj
and Cc Ck
, we can switch between char run
and line run
, but it is inconvenient. 我知道使用Cx Cj
和Cc Ck
可以在char run
和line run
之间切换,但这很不方便。 I prefer to use Cy
or Cc y
to do the job. 我更喜欢使用Cy
或Cc y
来完成这项工作。 Searched online but the solutions didn't work with my emacs23. 在线搜索,但解决方案不适用于我的emacs23。
There's two options here: use the inferior process or Emacs. 这里有两个选择:使用下级进程或Emacs。
To use the inferior process (probably something that uses readline), just send raw Cy
characters. 要使用劣等程序(可能使用readline),只需发送原始Cy
字符即可。
(define-key term-raw-map (kbd "C-k") 'term-send-raw)
(define-key term-raw-map (kbd "C-y") 'term-send-raw)
Then Ck
and Cy
get sent directly to the terminal, where they function like they would in any other terminal (eg kill to end of line and yank, respectively). 然后Ck
和Cy
被直接发送到终端,它们在该终端中的功能就像在其他终端中一样(例如,分别杀死到行尾和yank)。 Since the inferior process is receiving and interpreting the keypresses, Emacs will have nothing to do with the kills and yanks. 由于次等过程正在接收和解释按键,因此Emacs与杀戮和猛击无关。
To use Emacs's kill ring, use term-paste
. 要使用Emacs的kill环,请使用term-paste
。
(define-key term-raw-map (kbd "C-c C-y") 'term-paste)
Personally, I like to treat term-mode
buffers like regular terminals, so I usually use the mouse to copy/paste and Ck
/ Cy
when I'm editing a command line. 就个人而言,我喜欢将term-mode
缓冲区像普通终端一样对待,因此在编辑命令行时,通常使用鼠标复制/粘贴和Ck
/ Cy
。
FWIW, I use multiterm , and I do FWIW,我使用multiterm ,我这样做
(with-eval-after-load "multi-term"
(dolist
(bind '(("C-k" . term-send-raw)
("C-y" . term-send-raw)
("C-c C-y" . term-paste)
))
(add-to-list 'term-bind-key-alist bind)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.