GNU Emacs Manual. Node: Balanced Editing

PREVComments UPPrograms NEXTSymbol Completion

20.8: Editing Without Unbalanced Parentheses


Put parentheses around next sexp(s) (insert-parentheses).

M-) Move past next close parenthesis and reindent (move-past-close-and-reindent).

The commands M-( (insert-parentheses) and M-) (move-past-close-and-reindent) are designed to facilitate a style of editing which keeps parentheses balanced at all times. M-( inserts a pair of parentheses, either together as in `()', or, if given an argument, around the next several sexps. It leaves point after the open parenthesis. The command M-) moves past the close parenthesis, deleting any indentation preceding it, and indenting with C-j after it.

For example, instead of typing ( F O O ), you can type M-( F O O, which has the same effect except for leaving the cursor before the close parenthesis.

M-( may insert a space before the open parenthesis, depending on the syntax class of the preceding character. Set parens-require-spaces to nil value if you wish to inhibit this.

PREVComments UPPrograms NEXTSymbol Completion