How to Edit Lisp Code with Emacs

By Xah Lee. Date: . Last updated: .

This page shows you how to edit lisp code with plain emacs efficiently.

Auto Highlight Parenthesis: show-paren-mode

Emacs: Auto Highlight Parenthesis: show-paren-mode

Turn on parenthesis highlight.

Inserting Brackets by Pairs

Emacs: Insert Parenthesis by Pair: electric-pair-mode

You should ALWAYS insert brackets by pair. I ALWAYS. Also, always delete them by pairs (I do this by selecting the whole bracket expression and delete it. Almost never do i need to only delete the brackets). Insert and delete brackets by pair will save you a lot trouble in bracket matching.

Freely Moving Cursor to Brackets

It's critical to have keys that move cursor to previous opening bracket and next closing bracket.

See: Emacs: Move Cursor to Brackets, Quotes.

Navigate Lisp Code as Tree

You can also move cursor to brackets in such way as navigating a tree.

This is less useful than the freely moving to any bracket.

See: Emacs: Navigate Lisp Code as Tree

Select Lisp Expression by Unit

Call mark-sexpCtrl+Alt+Space】 to select a complete parenthesized expression. Your cursor must be on the left bracket.

To select a complete sexp, type 【Ctrl+Alt+】 (backward-up-list) then 【Ctrl+Alt+Space】.

Like it? Buy Xah Emacs Tutorial. Thanks.

or, buy something from my keyboard store.