简体   繁体   English

Emacs Clojure-移动括号

[英]Emacs Clojure - move parens

Is there an Emacs package for moving Lisp (Clojure specifically) S-expressions around ? 是否有一个Emacs软件包可用于移动Lisp(特别是Clojure)S表达式?

Note : I keep seeing how to move the cursor between S-Expressions, but this is not what I am looking for. 注意 :我一直看到如何在S-Expressions之间移动光标,但这不是我想要的。 I want to move the expressions instead : 我想移动表达式:

I am looking for something like that : 我正在寻找这样的东西:

(a-fn 1 2 3)
'(another-thing 2 3 4)
↑cursor here

Then if I do something like "move sexp-up" of "swap-sexp", the result should be : 然后,如果我执行诸如“ swap-sexp”的“ move sexp-up”之类的操作,则结果应为:

↓cursor here
'(another-thing 2 3 4)
(a-fn 1 2 3)

The built-in transpose-sexps function should do what you want. 内置的transpose-sexps函数应该执行您想要的操作。

For much more structured s-expression editing that works well with Clojure, you should give ParEdit a try. 对于与Clojure一起使用的结构化的S表达式编辑,您应该尝试一下ParEdit

http://www.emacswiki.org/emacs/ParEdit http://www.emacswiki.org/emacs/ParEdit

lispy works with Clojure. lispy与Clojure合作。 Press w to move the sexp up, and s to move the sexp down. w向上移动sexp,按s向下移动sexp。

As mentioned, lispy and paredit are the packages you want to have a look at. 如前所述,lispy和paredit是您要查看的软件包。 Lispy has the advantage of short key bindings, but this comes at the cost of having to ensure the pointer is before/after a sexp and the active region is on. Lispy具有短键绑定的优点,但这是以必须确保指针在sexp之前/之后以及活动区域处于打开状态为代价的。

Paredit has longer key bindings, but does not have the restrictions on where the pointer is and the region doesn't need to be active. Paredit具有更长的键绑定,但是对指针的位置没有限制,并且该区域不需要处于活动状态。 I tend to use paredit - while it takes a bit of time to get use to it, once you have, it makes things very fast. 我倾向于使用paredit-尽管要花一点时间才能使用它,但是一旦使用它,它会使事情变得非常快。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM