GNU Emacs Manual - Programs

Go to the first, previous, next, last section, table of contents.

# Editing Programs

Emacs has many commands designed to understand the syntax of programming languages such as Lisp and C. These commands can

- Move over or kill balanced expressions or sexps (see section Lists and Sexps).
- Move over or mark top-level expressions---defuns, in Lisp; functions, in C (see section Defuns).
- Show how parentheses balance (see section Automatic Display Of Matching Parentheses).
- Insert, kill or align comments (see section Manipulating Comments).
- Follow the usual indentation conventions of the language (see section Indentation for Programs).

The commands for words, sentences and paragraphs are very useful in editing code even though their canonical application is for editing human language text. Most symbols contain words (see section Words); sentences can be found in strings and comments (see section Sentences). Paragraphs per se don't exist in code, but the paragraph commands are useful anyway, because programming language major modes define paragraphs to begin and end at blank lines (see section Paragraphs). Judicious use of blank lines to make the program clearer will also provide useful chunks of text for the paragraph commands to work on.

The selective display feature is useful for looking at the overall structure of a function (see section Selective Display). This feature causes only the lines that are indented less than a specified amount to appear on the screen.

Go to the first, previous, next, last section, table of contents.