15
votes

I'm doing my first steps with Clojure, but for some reason the up/down keys don't allow me to step through the command history in the REPL like in REPLs of other languages. Does the Clojure REPL use different keys to access the command history, or is this feature just not (yet) implemented?

5

5 Answers

21
votes

If you are, by any chance, using a Unix-like environment you can use rlwrap to to achieve nice things like command line history and Ctrl-R for searching through it.

Just prepend your command which you use to start repl, e.g:

rlwrap java -cp clojure.jar clojure.main

8
votes

Or use Leiningen or Cake. Either of these are useful in general, and you'll be happy to learn to use them, but specifically they use readline or jline automatically where available.

6
votes

You can enhance the REPL to do this by using JLine, see here.

2
votes

Depends which REPL you use. Most good REPLs have this functionality and more.

If you're coming from Java as an Eclipse user, for example, you may want to use the embedded nREPL provided by the Counterclockwise plugin. I found this easier to use than configuring a separate dedicated Clojure environment.

1
votes

C-, M-x slime-repl-forward-input C-, M-x slime-repl-backward-input Go to the next/previous history item.

http://common-lisp.net/project/slime/doc/html/Input-Navigation.html