In emacs term-mode, what is char-mode and line-mode? How do they differ

emacs

Googling, I can only find how to switch between these two, but no description of what they are.

So, what is char-mode and line-mode? And what mode are usually regular shells in?

Best Answer

As in the page you linked:

In line mode, Term basically acts like Shell mode (see Shell Mode). In char mode, each character is sent directly to the subshell, except for the Term escape character, normally C-c.

In line mode, it reads an entire line and permits various emacs editing operations on it, then sends it to the process all at once when you're done (press Enter). In char mode, each character is sent through as soon as you press the key - dealing with lines, editing, and so on is up to the process running in the terminal, such as your shell.

Why might you want to use one over the other? Line mode allows you to perform Emacs editing operations on what you write, to accumulate multiple lines to send through at once, and to perform tab completion of filenames in Emacs. See the list of commands in shell mode for details. Character mode lets you use all the features of the underlying process, like its own (likely better) tab completion, rather than the Emacs operations, and also to send through inputs that Emacs would have interpreted as referring to its own commands (like Ctrl-X). This is also the mode you'd want if you wanted to run vim inside emacs.

An ordinary terminal operates in the equivalent of character mode.