Inspector
The value inspector allows you to inspect and navigate the structure of data. While you can use it for pretty much anything (e.g. primitive data types, var, ref types) it’s most useful when you’re dealing with (deeply) nested collection-like data types (e.g. a vector of maps).
Usage
Typing C-c M-i (cider-inspect) after some form in a source
buffer or the REPL will show you the structure of the form’s result
in a new buffer. You can also use C-u C-c M-i to inspect
the result of the current top-level form and C-u C-u C-c M-i to
read an expression from the minibuffer and inspect its result.
Alternatively, after a regular eval command, you can inspect the last
evaluated value using cider-inspect-last-result. When an inspector
buffer is visible in the background, it is automatically updated with
the last result. This behavior can be controlled with the variable
cider-auto-inspect-after-eval.
| The inspector can also be invoked in the middle of a debugging session, see here for more details. |
The current value of the debugger can be sent as well to Clojure’s
tap> facility. This can be used to integrate CIDER with various external
tools which render tapped values in a web browser, for example.
|
You’ll have access to additional keybindings in the inspector buffer
(which is internally using cider-inspector-mode). All bindings are listed
at the bottom of the inspector buffer in the Keybindings section. It can be
toggled by pressing ?.
| Keyboard shortcut | Command | Description |
|---|---|---|
Tab and Shift-Tab / n and p |
|
Navigate inspectable sub-objects |
Return |
|
Inspect sub-objects |
l |
|
Pop to the parent object |
g |
|
Refresh the inspector (e.g. if viewing an atom/ref/agent) |
SPC or Next |
|
Jump to next page in paginated view |
M-SPC or Prev |
|
Jump to previous page in paginated view |
y |
|
Calculate and display analytics for the inspected object. Analytics is supported for lists of numbers, strings, tuples, maps; for large key-value maps. |
s |
|
Set a new page size in paginated view |
c |
|
Set a new maximum size above which nested collections are truncated |
C |
`cider-inspector-set-max-nested-depth |
Set a new maximum nesting level above which the collections are truncated |
a |
|
Set a new maximum length above which nested atoms (non-collections) are truncated |
v |
|
Switch the rendering of the current value between |
P |
|
Toggle the pretty printing of values in the inspector. You can set the |
S |
|
Toggle the sorting of maps by key in the inspector. You can set the |
D |
|
When inspecting a diff result, toggle only displaying the differing values. You can set the |
d |
|
Defines a var in the REPL namespace with current inspector value. If you tend to always choose the same name(s), you may want to set the |
C-c C-p |
|
Print the current value of the inspector to the |
9 |
|
Navigates to the previous sibling, within a sequential collection. |
0 |
|
Navigates to the next sibling, within a sequential collection. |
o |
|
Opens the url or file at point, if found. |
: |
|
Prompts for a new value, rendering it in the Inspector. |
t |
|
Performs |
1 |
|
Performs |
? |
|
Toggles the |
View modes
The point of the inspector is to display and navigate familiar data structures
in a more pleasant and obvious way. For example, in the inspector, a sequential
collection is rendered with each item on its own line and paginated. However,
for some object types, inspector supports additional view modes. The modes can
be cycled by calling cider-inspector-toggle-view-mode (v by default).
-
:object- default view mode for rendering any Java object that doesn’t have a custom renderer. Displays all object fields and their values. Known types can also be switched to this mode. -
:table- can be enabled when inspecting a sequence of maps when each map has same or mostly same keys. -
:hex- available for byte arrays and ByteBuffer objects, renders them in a "hexdump" style.
Configuration
You can see and change all variables related to Inspector by doing M-x
customize-group cider-inspector.
You can set the amount of data shown by default with the variables
cider-inspector-page-size, cider-inspector-max-coll-size,
cider-inspector-max-nested-depth, and cider-inspector-max-atom-length. The
values can be adjusted for the current inspector buffer using the keybindings
listed in the table above.
When cider-inspector-tidy-qualified-keywords is enabled, namespace-qualified
keyword like ::foo or ::alias/baz will be displayed in the same manner by
the inspector if it was invoked in the code buffer of the same namespace or
requires respective aliases.