Keybindings

This is the reference for `cider-mode’s keybindings - the commands available in Clojure(Script) source buffers once you’ve connected a REPL. They’re grouped by task; the printable quick-reference card covers the same ground on a single page.

This page covers source-buffer bindings. A few related references:

  • The REPL buffer has its own bindings - see REPL Keybindings.

  • Feature pages carry the bindings specific to their tools (e.g. the debugger, the inspector, and the buffer-local browsers in Code Navigation and Browsing).

  • Many commands do something extra when invoked with a prefix argument (C-u). Use C-h k on a binding for the full story.

Discovering keybindings

Emacs can always tell you what’s bound right now, which is handy given CIDER’s many prefix keys:

Keyboard shortcut Description

C-h m

Describe the current major/minor modes, including a full list of active bindings.

C-h k key

Describe the command bound to key.

C-h b

List all key bindings active in the current buffer.

prefix C-h

Show every binding that starts with prefix (e.g. C-c C-d C-h).

Install which-key and CIDER’s prefixes become self-documenting - pause after a prefix like C-c C-d and a popup lists the keys that follow. See Using cider-mode for more.

Starting and stopping CIDER

C-c C-x opens the cider-start-menu transient, from which you pick how to start or connect to a session. The most common entries:

Keyboard shortcut Command Description

C-c C-x j j

cider-jack-in-clj

Start an nREPL server for the project and connect to it (Clojure).

C-c C-x j s

cider-jack-in-cljs

Start an nREPL server and connect to it (ClojureScript).

C-c C-x j m

cider-jack-in-clj&cljs

Start a server and connect both a Clojure and a ClojureScript REPL.

C-c C-x c j

cider-connect-clj

Connect to an already-running nREPL server (Clojure).

C-c C-x c s

cider-connect-cljs

Connect to an already-running nREPL server (ClojureScript).

C-c C-q

cider-quit

Quit the current connection.

C-c M-r

cider-restart

Restart the current connection.

C-c C-x shows the whole menu (jack-in, connect, connect-sibling), so you don’t have to memorize the suffixes. See Up and Running.

Evaluating code

Keyboard shortcut Command Description

C-x C-e (also C-c C-e)

cider-eval-last-sexp

Evaluate the form preceding point and show the result in the echo area.

C-c C-c (also C-M-x)

cider-eval-defun-at-point

Evaluate the top-level form containing point (redefine it in the running program).

C-c C-v v

cider-eval-sexp-at-point

Evaluate the form around point.

C-c C-v l

cider-eval-list-at-point

Evaluate the list around point.

C-c C-v r

cider-eval-region

Evaluate the active region.

C-c C-v s

cider-eval-dwim

Evaluate the region if one is active, otherwise the top-level form.

C-c C-v z

cider-eval-defun-up-to-point

Evaluate the enclosing top-level form up to point.

C-c C-v w

cider-eval-last-sexp-and-replace

Evaluate the form preceding point and replace it with the result.

C-c M-e

cider-eval-last-sexp-to-repl

Evaluate the form preceding point and send the result to the REPL.

C-c C-p

cider-pprint-eval-last-sexp

Evaluate the form preceding point and pretty-print the result in a popup.

C-c C-f

cider-pprint-eval-defun-at-point

Evaluate the top-level form and pretty-print the result in a popup.

C-c C-v C-f v

cider-pprint-eval-sexp-at-point

Evaluate the form at point and pretty-print the result in a popup.

C-c M-;

cider-eval-defun-to-comment

Evaluate the top-level form and insert the result as a comment.

C-c M-:

cider-read-and-eval

Read a Clojure expression from the minibuffer and evaluate it.

C-c M-i

cider-inspect

Evaluate an expression and open the result in the inspector.

C-c C-i

cider-inspect-menu

Open a menu listing every way to start an inspection (last sexp, sexp at point, defun, last result, or an expression you type).

See Code Evaluation for the evaluation commands and their prefix-argument variations.

Loading code

Keyboard shortcut Command Description

C-c C-k

cider-load-buffer

Load (evaluate) the current buffer.

C-c C-l

cider-load-file

Load a file, prompting for its name.

C-c C-M-l

cider-load-all-files

Load all files under a directory, prompting for it.

Keyboard shortcut Command Description

M-.

cider-find-var

Jump to the definition of the symbol at point.

M-,

cider-pop-back

Return to where you were before the last jump.

C-c C-.

cider-find-ns

Jump to a namespace, selected via completion.

C-c C-:

cider-find-keyword

Jump to the definition of the namespaced keyword at point.

C-c M-.

cider-find-resource

Jump to a classpath resource referenced by the string at point.

C-c C-? r

cider-xref-fn-refs

Show the usages of the function at point in a dedicated buffer.

C-c C-? C-r

cider-xref-fn-refs-select

Show the usages of the function at point in a minibuffer selector.

C-c C-? s

cider-xref-fn-refs-in-source

Search the project’s source for references to the symbol at point.

C-c C-? d

cider-xref-fn-deps

Show the functions used by the function at point.

C-c C-? C-d

cider-xref-fn-deps-select

Show the functions used by the function at point in a minibuffer selector.

C-c C-w c

cider-who-calls

Browse the callers of the function at point as a tree.

C-c C-w d

cider-who-is-called

Browse the functions the function at point calls, as a tree.

C-c C-w m

cider-who-macroexpands

Find a macro’s use sites by searching the project’s source.

C-c C-w i

cider-who-implements

Browse the types that implement the protocol at point.

C-c C-w t

cider-type-protocols

Browse the protocols a type implements.

C-c C-w p

cider-protocols-with-method

Browse the protocols that declare a given method.

C-c M-s

cider-selector

Quickly jump to an important buffer (REPL, docs, stacktrace, etc.).

See Code Navigation and Browsing for the complete navigation and call-graph toolkit.

Looking up documentation

Keyboard shortcut Command Description

C-c C-d d

cider-doc

Show documentation for the symbol at point.

C-c C-d j

cider-javadoc

Open the Javadoc for the symbol at point in a browser.

C-c C-d a

cider-apropos

Search for definitions matching a pattern.

C-c C-d f

cider-apropos-documentation

Search documentation strings matching a pattern.

C-c C-d c

cider-clojuredocs

Show ClojureDocs documentation for the symbol at point.

C-c C-d w

cider-clojuredocs-web

Open the symbol’s ClojureDocs page in a browser.

Macroexpansion

C-c M-m opens the cider-macroexpand-menu transient; the keys below are its suffixes, so C-c M-m a means "open the menu, then press a".
Keyboard shortcut Command Description

C-c C-m (also C-c M-m 1)

cider-macroexpand-1

Expand the macro call at point once.

C-c M-m a

cider-macroexpand-all

Fully expand the macro call at point.

C-c M-m v

cider-macroexpand-1-at-point

Expand the call at point once, without moving point after it first.

C-c M-m V

cider-macroexpand-all-at-point

Fully expand the call at point.

C-c M-m e

cider-macrostep-expand

Step through the expansion inline in the source buffer (requires macrostep).

C-c M-m E

cider-macrostep-expand-all

Fully expand the macro at point inline in the source buffer.

C-c M-m b

cider-macrostep-expand-in-buffer

Run a macro-stepping session in a dedicated popup buffer.

See Macroexpansion for details.

Working with namespaces

Keyboard shortcut Command Description

C-c M-n n

cider-repl-set-ns

Switch the REPL to the current buffer’s namespace.

C-c M-n e

cider-eval-ns-form

Evaluate the ns form of the current buffer.

C-c M-n r

cider-ns-refresh

Reload changed namespaces (via clojure.tools.namespace).

C-c M-n l

cider-ns-reload

Reload the current namespace with require :reload.

C-c M-n b

cider-browse-ns

Browse the contents of a namespace.

C-c C-u

cider-undef

Undefine a symbol.

C-c C-M-u

cider-undef-all

Undefine all symbols and aliases in the namespace.

See Code Reloading for the reloading workflow.

Testing

Keyboard shortcut Command Description

C-c C-t t

cider-test-run-test

Run the test at point.

C-c C-t n

cider-test-run-ns-tests

Run the tests in the current namespace.

C-c C-t l

cider-test-run-loaded-tests

Run all currently loaded tests.

C-c C-t p

cider-test-run-project-tests

Run all the project’s tests.

C-c C-t a

cider-test-rerun-test

Re-run the last test you ran.

C-c C-t r

cider-test-rerun-failed-tests

Re-run only the failing tests.

C-c C-t b

cider-test-show-report

Show the test report buffer.

See Running Tests for the full test runner.

Debugging and tracing

Keyboard shortcut Command Description

C-u C-M-x (also C-u C-c C-c)

cider-eval-defun-at-point

Instrument the top-level form and step through it in the debugger.

C-c M-t v

cider-toggle-trace-var

Toggle tracing of the var at point.

C-c M-t n

cider-toggle-trace-ns

Toggle tracing of a whole namespace.

See Debugger and Tracing.

Interacting with the REPL

Keyboard shortcut Command Description

C-c C-z

cider-switch-to-repl-buffer

Switch between the source buffer and the REPL.

C-c M-z

cider-load-buffer-and-switch-to-repl-buffer

Load the current buffer and switch to the REPL.

C-c M-p

cider-insert-last-sexp-in-repl

Copy the form preceding point into the REPL prompt.

C-c C-j v

cider-insert-sexp-at-point-in-repl

Copy the form at point into the REPL prompt.

C-c C-j c

cider-send-defun-to-comment

Copy the top-level form into the namespace’s rich comment block.

C-c C-j j

cider-jump-to-comment

Move point into the namespace’s rich comment block.

C-c C-o

cider-find-and-clear-repl-output

Clear the output of the last evaluation from the REPL.

C-c M-d

cider-describe-connection

Show information about the current connection.

C-c C-b

cider-interrupt

Interrupt any pending evaluations.

Completion

CIDER completes the symbol at point through the standard completion-at-point mechanism, so it’s normally bound to M-TAB (and triggered automatically by completion UIs like company or corfu). See Code Completion for details.

Printable reference card

CIDER also ships a one-page, printable quick-reference card covering these essentials, meant to be printed and kept on your desk: download the PDF. Its LaTeX source is in the refcard directory of the CIDER repository.