Insert word into ansi-term on Emacs

I use ansi-term on Emacs and you need to insert a few words there. "Paste" only works with the middle of the mouse. I know that with Cx Cj and Cc Ck we can switch between char run and line run , but this is inconvenient. I prefer to use Cy or Cc y to do the job. Searched online, but solutions did not work with my emacs23.

+4
source share
1 answer

There are two options: use the bottom process or Emacs.

To use the bottom process (maybe something that uses readline), just send the raw Cy characters.

 (define-key term-raw-map (kbd "Ck") 'term-send-raw) (define-key term-raw-map (kbd "Cy") 'term-send-raw) 

Then Ck and Cy sent directly to the terminal, where they function in the same way as in any other terminal (for example, kill to the end of the line and yank, respectively). Since the bottom process accepts and interprets keystrokes, Emacs will have nothing to do with killing and Yankees.

To use the Emacs kill ring, use term-paste .

 (define-key term-raw-map (kbd "Cc Cy") '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 editing the command line.

FWIW, I use multiterm , and I do

 (with-eval-after-load "multi-term" (dolist (bind '(("Ck" . term-send-raw) ("Cy" . term-send-raw) ("Cc Cy" . term-paste) )) (add-to-list 'term-bind-key-alist bind))) 
+2
source

All Articles