Artificial intelligent assistant

How can you achieve vi's `se ai` in Emacs? What's the simplest way to set up auto indentation in Emacs? I can see that auto-fill correctly wraps, say: This is an indented block, and the wrapping happens as expected. On the other hand, I get this unwanted behavior: This is an indented short line. I'm now taken to the beginning of the line. I expected to be under the "T". In other words, how can I get the equivalent of vi's `se ai` in Emacs?

Posting comments as an answer so this question has a formal answer...

The short answer is that for a buffer in "fundamental mode", run `M-x electric-indent-mode`

Emacs is modal, and each mode selects the kind of auto-indentation that is appropriate for that mode. For example, if you edit a text file, you will be in "text mode" and lines will by default automatically respect indentation of a prior line.

When Emacs doesn't find a special a mode for the buffer you are editing, it defaults to something called "Fundamental Mode". The document string for this is:


Major mode not specialized for anything in particular.
Other major modes are defined by comparison with this one.


The way many modes handle auto-indentation is to use a minor mode called "electic-indent-mode" (A minor mode is a variation added to a major mode like "fundamental mode").

Finally, as indicated in the comments, Emacs Wiki has more information on indentation.

xcX3v84RxoQ-4GxG32940ukFUIEgYdPy b75d15b5ad6fdfaac92ef51ace1209d7