Send EOF (^D) to emacs ansi-term

2.2k views Asked by At

When I use ansi-term mode in Emacs, and run a program such as cat, ^D does not end the input like it normally does. If fact, it doesn't seem to do anything at all.

^C still works.

I have Evil installed

2

There are 2 answers

2
Gordon Gustafson On BEST ANSWER

Try adding these to your config (after you load evil):

(delete 'term-mode evil-insert-state-modes)
(add-to-list 'evil-emacs-state-modes 'term-mode)

On my emacs with this modification, cat followed by ^D in ansi-term char-mode ends the input and bring me back to the prompt. Make sure you know the difference between char-mode and line-mode like tripleee mentioned!

2
tripleee On

ansi-term has two different input submodes. To send a literal C-d in the default (character) mode, just press C-d. However, if you are in line mode, you need C-c C-d. Or you can switch to character mode with C-c C-k (and back to line mode with C-c C-j).

See also the documentation.