When I first started using CIDER I was intimidated by the block of 41
cider-mode and 25
cider-repl-mode interactive commands (to be fair, there's a lot of overlap between the
two). Luckily you only need a small subset of these commands at your fingertips to be very
REPLs and Namespaces
Open a project file (created with Leiningen or Boot) and in that buffer
C-c M-j to
launch an nREPL server and corresponding REPL client. This client will be associated with
your project. You can see the nREPL server in the mode line – in my case:
You're done with your REPL and you want to quit:
C-c C-q. This is one of those commands I wish
I'd seen earlier. I spent so much time killing nREPL buffers manually.
From your clojure buffer you can use
C-c C-n to switch to this namespace in the REPL.
C-z actually switches to the associated REPL buffer (and back!).
Load your current buffer with
C-c C-k. You can do form evaluation a few different ways, here are
C-c C-e: eval the form to the left of the cursor (the pipe below) and show the result inline.
(map #(* % %) (take 5 (range))|) => (0 1 2 3 4)
C-c C-c: eval the top-level form at point and show the result inline.
(map #(* % %) (take 5 (range))|) => (0 1 4 9 16)
- Bonus: Try
C-c C-ffor pretty-printed popup buffer versions of the previous two evals, respectively. Useful for copying output.
Other Useful Tools
A few other basic but high impact functions include:
- Jump you to the definition of the symbol at point with
- See clojure docs for the symbol at point via
C-c C-d dand java docs with
C-c C-d j.
- In the REPL
C-c C-owill remove the result of the previous evaluation, useful especially when you have a verbose output clogging up your workspace. With the prefix argument,
C-u, it will remove all previous output.