clojure Emacs CIDER Pretty Print


Example

CIDER function cider-insert-last-sexp-in-repl can be used to execute the the code while editing the code inside the buffer and get the output pretty printed in a different buffer. This function is by default binded to C-c C-p.

CIDER manual says C-c C-p will

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

For example

(def databases {:database1  {:password "password"
                             :database "test"
                             :port "5432"
                             :host "localhost"
                             :user "username"}
                  
                :database2 {:password "password"
                            :database "different_test_db"
                            :port "5432"
                            :host "localhost"
                            :user "vader"}})

(defn get-database-config
  []
  databases)

(get-database-config)

Performing C-c C-p while your cursor is just ahead of the ending paren of get-database-config function call will output the pretty printed map in a new popup buffer.

{:database1
 {:password "password",
  :database "test",
  :port "5432",
  :host "localhost",
  :user "username"},
 :database2
 {:password "password",
  :database "different_test_db",
  :port "5432",
  :host "localhost",
  :user "vader"}}