Fork me on GitHub
#editors
<
2018-07-13
>
jeremy02:07:05

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.

pesterhazy14:07:36

@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.

pesterhazy14:07:41

(There's a "lisp mini state" (`SPC k`), but I don't like it at all for navigation.)

andre.stylianos14:07:24

Just to see if I understand correctly, you want a command that changes: (defn something [] (println |"ok")) to (defn something [] (println "ok"|)) ?

andre.stylianos14:07:23

Because in spacemacs I use ] for that, I think it's that way by default

andre.stylianos14:07:15

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]|)

jeremy15:07:23

@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.

jeremy15:07:35

@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.

andre.stylianos15:07:02

Ah, sorry @jeremy642, seems like it's not default behavior but part of evil-cleverparens

jeremy15:07:17

I will check that out, thanks.