2

I use Vim for Clojure development. I'd like a movement key or mapping that will jump through the top-level forms in the buffer. { and } are close, but stop if there's a blank line in the middle of the form. slimv-paredit's ( and ) move within a top-level forms. Here's an example:

(def foo :bar)
(defn plus [x y]
  (+ x y))

(def yum :cat)

Assuming the cursor starts at the top, I'd like to jump to the opening paren of foo, plus, and then yum.

Tamas Kovacs
  • 1,495
  • 7
  • 9
Dave Ray
  • 39,616
  • 7
  • 83
  • 82

2 Answers2

4

I have added mappings [[ and ]] for moving to the previous/next defun in Slimv's paredit.vim. Please fetch it from the Slimv repository.

Tamas Kovacs
  • 1,495
  • 7
  • 9
  • Nice. Two issues: on line 41 of [this file](https://github.com/daveray/seesaw/blob/develop/src/seesaw/core.clj#L41) (the `(defn native! ...` line), "back" doesn't seem to work. Also it stops on parens in comments. See the copyright notice at the top of the same file. Otherwise, this is what I was looking for. Thanks! – Dave Ray Sep 05 '11 at 16:59
  • Thanks for the bug report, I have fixed it. If you still experience problems, please let me know. – Tamas Kovacs Sep 06 '11 at 07:29
2

You can write a quick vim macro to do what you want. Put this in your .vimrc:

map \n /^(<CR>

When you press \n, you'll hop to the next form that starts on a line.

thedayturns
  • 9,723
  • 5
  • 33
  • 41