开发者

Navigating top-level Lisp/Clojure forms in Vim

I use Vim for Clojure development. I'd like a movement key or mapping that will jump through the top-level forms in th开发者_开发技巧e 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.


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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜