(emacs)List Commands

Next: Defuns Prev: Lists Up: Programs

List And Sexp Commands

     Move forward over a sexp (`forward-sexp').

     Move backward over a sexp (`backward-sexp').

     Kill sexp forward (`kill-sexp').

     Move up and backward in list structure (`backward-up-list').

     Move down and forward in list structure (`down-list').

     Move forward over a list (`forward-list').

     Move backward over a list (`backward-list').

     Transpose expressions (`transpose-sexps').

     Put mark after following expression (`mark-sexp').

   To move forward over a sexp, use `C-M-f' (`forward-sexp').  If the
first significant character after point is an opening delimiter (`(' in
Lisp; `(', `[' or `{' in C), `C-M-f' moves past the matching closing
delimiter.  If the character begins a symbol, string, or number,
`C-M-f' moves over that.

   The command `C-M-b' (`backward-sexp') moves backward over a sexp.
The detailed rules are like those above for `C-M-f', but with
directions reversed.  If there are any prefix characters (single-quote,
backquote and comma, in Lisp) preceding the sexp, `C-M-b' moves back
over them as well.  The sexp commands move across comments as if they
were whitespace in most modes.

   `C-M-f' or `C-M-b' with an argument repeats that operation the
specified number of times; with a negative argument, it moves in the
opposite direction.

   Killing a sexp at a time can be done with `C-M-k' (`kill-sexp').
`C-M-k' kills the characters that `C-M-f' would move over.

   The "list commands" move over lists like the sexp commands but skip
blithely over any number of other kinds of sexps (symbols, strings,
etc).  They are `C-M-n' (`forward-list') and `C-M-p' (`backward-list').
The main reason they are useful is that they usually ignore comments
(since the comments usually do not contain any lists).

   `C-M-n' and `C-M-p' stay at the same level in parentheses, when
that's possible.  To move *up* one (or N) levels, use `C-M-u'
(`backward-up-list').  `C-M-u' moves backward up past one unmatched
opening delimiter.  A positive argument serves as a repeat count; a
negative argument reverses direction of motion and also requests
repetition, so it moves forward and up one or more levels.

   To move *down* in list structure, use `C-M-d' (`down-list').  In
Lisp mode, where `(' is the only opening delimiter, this is nearly the
same as searching for a `('.  An argument specifies the number of levels
of parentheses to go down.

   A somewhat random-sounding command which is nevertheless handy is
`C-M-t' (`transpose-sexps'), which drags the previous sexp across the
next one.  An argument serves as a repeat count, and a negative
argument drags backwards (thus canceling out the effect of `C-M-t' with
a positive argument).  An argument of zero, rather than doing nothing,
transposes the sexps ending after point and the mark.

   To make the region be the next sexp in the buffer, use `C-M-@'
(`mark-sexp') which sets mark at the same place that `C-M-f' would move
to.  `C-M-@' takes arguments like `C-M-f'.  In particular, a negative
argument is useful for putting the mark at the beginning of the
previous sexp.

   The list and sexp commands' understanding of syntax is completely
controlled by the syntax table.  Any character can, for example, be
declared to be an opening delimiter and act like an open parenthesis.
Note: Syntax.

automatically generated by info2www