开发者

Navigating top-level Lisp/Clojure forms in Vim

开发者 https://www.devze.com 2023-04-02 09:31 出处:网络
I useVim 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 t

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

精彩评论

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