I’m using Spacemacs/Cider in Evil mode and I’m wondering what commands I might use to quickly jump to the end parens from the closure i am currently in. For example when I need to add more code after a () but the end parens is buried in the closing ))))))))) of the defn.
@jeremy642 I'd also like to know if there is a built-in way to do this. What I do is to define a key U
for "up":
(evil-global-set-key 'normal "U" 'backward-up-list)
(evil-global-set-key 'visual "U" 'backward-up-list)
which focusses the opening parenthesis; then I use %
to switch to the matching closing parenthesis.(There's a "lisp mini state" (`SPC k`), but I don't like it at all for navigation.)
Just to see if I understand correctly, you want a command that changes:
(defn something [] (println |"ok"))
to
(defn something [] (println "ok"|))
?
Because in spacemacs I use ]
for that, I think it's that way by default
Wait, wrong shortcut.
]
moves your cursor to the next closing )
, ]
, }
or etc regardless of the form you're on. (let | [a 1])
will become (let [a 1|])
but )
does what you probably asked for: (let | [a 1])
will become (let [a 1]|)
@pesterhazy Found out that % will move you back and forth between the current parens in the sexp. So if I can bind my own way to move around the lists without going into lisp state that would be great. I also found out yesterday the lisp state commands for inserting a new sexp above and below the current sexp which is awesome but I might have to rebind too.
@andre.stylianos Were you replying to me? Mostly I was trying to figure out how to navigate around the lisp, jumping from an opening or inside an sexp to the end of the sexp so that I could insert another sexp below it.
Yup, @jeremy642
Ah, sorry @jeremy642, seems like it's not default behavior but part of evil-cleverparens
I will check that out, thanks.