14

Upon starting term-mode, Emacs delegates all keypresses to the terminal you're running.

That's great for compatibility purposes, but leaves Emacs functionality behind. How do I get back to Emacs features (for example, to switch a buffer).

zck
  • 9,092
  • 2
  • 33
  • 65

1 Answers1

16

In term-mode, there are two input modes. In the default input mode -- char-mode -- all keypresses (except C-c) are sent to the terminal to do what it wishes with.

If you change the input mode to line-mode, then regular Emacs commands work. You can switch to line-mode with C-c C-j. You can switch back to char-mode with C-c C-k.

zck
  • 9,092
  • 2
  • 33
  • 65
  • 5
    Note that there is also term-escape-char (defaults to C-c). This keypress is not sent to the terminal directly even in char-mode, but is translated to C-x. With its help you can switch from a char-mode term buffer to a different window using C-c o (translated to C-x o), to a different buffer with C-c b (C-x b), get a list of buffers with C-c C-b (C-x C-b), etc. – Constantine Dec 23 '14 at 20:56
  • 1
    How can I make line-mode the default ? – haknick Oct 10 '15 at 04:28
  • 1
    @haknick I'm not sure offhand -- you should ask a separate question about that, and see if anyone knows. – zck Oct 10 '15 at 06:07
  • Unfortunately, the commands that I'd want to use most often in a terminal window aren't on C-x : those related to marking (C-space and so on) and scrolling (pgup / pgdown). Having to switch to line mode and back for these would be absurdly laborious. Looks like for term to be useful for running a shell one would need some intermediate layer like screen -- in which case there is little point. – q.undertow Sep 26 '23 at 18:35