Emacs has various editing modes in each of which it behaves slightly differently. When you often want features like word wrap so you don't have to press <Return> at the end of the line, you can set text mode. When you are programming, your code must be formatted; for example, for programming in C set C mode.
Text mode and C mode are major modes. A buffer can be in only one major mode at a time; to exit a major mode, you have to enter another one.
Whenever you edit a file, emacs attempts to put you into the correct major mode for what you are going to edit. If you are editing a file with the ending .c, it puts you in the C mode. If the file has the ending .tex, it puts you in the TeX mode. If emacs can't determine a special mode, it puts you in the fundamental mode, the most general of all modes.
You can also change the mode manually with the command:
<Esc-x> startup-command <Return>.
The important major modes and their startup-commands are in the following table:
Mode Description Startup-commandFundamental The default mode; no special behavior. fundamental-mode
Text For writing text. text-mode
Directory For editing directory contents. dired-mode
Indented text Indents all the text you type. indented-text-mode
Picture For creating simple drawings. picture-mode
C For writing C programs. c-mode
FORTRAN For writing FORTRAN programs. fortran-mode
nroff For formatting file for nroff. nroff-mode
TeX For formatting file for TeX. tex-mode
LaTeX For formatting file for LaTeX. latex-mode
Outline For writing outlines. outline-mode
View For viewing files but not editing. view-file
Mail For sending mail. mail
Read Mail For reading mail. rmail
In addition to the major modes there are also minor modes. These define a practical aspect of emacs and can be turned on and off within a major mode.
Abbrev Allows you to use word abbreviations. abbrev-modeFill Enable word wrap. auto-fill-mode
Overwrite Replaces characters as you type instead
of inserting them. overwrite-mode
Auto-save Saves your file automatically. auto-save-mode
In your $HOME/.emacs file, the startup file of emacs, you can set your favourite modes to be turned on automatically every time you start emacs.