• en | es

Clojure VIM Environment

The Cursive plugin for Clojure is now out of its beta testing phase. I have been using it throughout its beta program and, I must say, it is pretty good. Sure, the refactoring capabilities are not quite on a par with those of IntelliJ for Java, but then Clojure is dynamic and asking for that kind of power is asking for the impossible.

I, on the other hand, have found myself going back to vim more often when I am working with Clojure. I have always found the vim shortcuts more powerful. I even use the vim plugin in IntelliJ IDEA / Cursive. Luckily there are couple of plugins available that make Clojure development in vim a joy. These are Vim Clojure and Fireplace.

The basics I ask from a development environment are:

  1. Syntax Highlighting
  2. Fast keyboard based navigation through source code
  3. Jump to source and docs for third-party libs
  4. Fast test execution

Vim with Fireplace satisfies the basic and goes beyond that. My favourite is the block editing feature that allows me to manipulate blocks of code (e.g. replace everything within function call, copy all declarations inside a let block etc.). The plugin also automatically connects to a running repl and allows me to execute any Clojure code directly through vim. I find these features much more useful then the rudimentary refactoring such as “change function name”, although I do miss it sometimes. Note that Cursive also has an integreated repl. There is a very good tutorial for Fireplace here.

Here’s what my vim Clojure dev environment looks like:

I have found that some investment into learning better vim usage has allowed me to become more productive than I was with Cursive, although it will not suit everyones taste. The codebases I work on are relatively small and I may still prefer Cursive for larger codebases. Having said that, I like the argument that we should never have a single large codebase. At least for now vim is my new favourite editor for Clojure. Then again! I have not tried Emacs … yet!

EDIT: Tom Oram pointed out a couple more plugins that I neglected to mention. These are Rainbow Parentheses and Paredit. The former is invaluable for keeping track of those parentheses, and adds a little colour to your life. The later allows structured editing of s-expressions - it is not easy to get use to but once you do you cannot do without,

About the author

Mash is a pragmatic software craftsman always looking to improve his software creation skills and helping others do the same. He firmly believes that a well-rounded software craftsman must have a keen interest in all aspects of software creation, including; process, people, technology, user experience, development, operation, maintenance, and social impact. He relishes the daily challenges that Codurance brings to him–stretching his existing knowledge and expertise allowing him to constantly grow as a professional.

Mash is an advisor and a leader. During his diverse career, he has succeeded in invigorating large ailing software projects as well as creating highly effective software teams and departments. His broad and deep technical knowledge, organisational skills, craft focus, and empathy to people involved have been integral to his success. He has worked in many roles for charities, investment banks, consultancies, government, media and cloud providers. He prides himself at being a hands-on software developer and believes that software development skills are very hard to learn and the best way to maintain them is to apply them.