Skip to content

Smartparens - Writing structural textλ︎

Spacemacs uses Smartparens to write and navigate code quickly, ensuring the structure of the code does not break (i.e. no unbalanced parens).

smartparens keeps parens in balance by automatically creating a closing paren when you type an open paren, e.g () for lists, [] for vectors, {} for maps and "" for strings.

Smartparens strict modeλ︎

Enable strict mode to prevent the deletion of parens that would leave them unbalanced. For example, the characters within parens must be deleted before deleting both parens at the same time.

Space f e d to edit the Spacemacs configuration file and update dotspacemacs-smartparens-strict-mode to have a value of t

Spacemacs - Configuration - smart parents strict mode

Smartparens supports all languages

Smartparens is a newer implementation of paredit package and provides support for all languages, not just Clojure. Paredit and smartparens has a comparison of these two packages.

Jump past the end of an expressionλ︎

Using smart closing parenthesis, ) jumps to the end of the current expression.

C-q temporarily disables this feature, allowing a ) to be entered

dotspacemacs-smart-closing-parenthesis in .spacemacs controls this feature, set this to t to enable.

dotspacemacs-smart-closing-parenthesis t

Smartparens and symbol highlightingλ︎

Spacemacs highlights the surrounding symbols, including any parents. So if you are in a nested list, (parent code (nested code)), then if the cursor is on the nested code, both nested & parent symbols are highlighted.

A closing symbol is also highlighted when the cursor is at the opening symbol.