Fork me on GitHub

Trying to use vim sexp and for 10 minutes continuously every time I did something to the code, something completely surprising happened that I didn't understand even after undoing and retrying. It creates errors in the code and then doesn't let me fix them.


Bunch of demos on what the different motions do, but when the form doesn't fit the screen, and there are errors in the code, it's really hard to see what happens


I'm using the "vim-sexp-mappings-for-regular-people" or whatever the name is, but in the end I've mapped ctrl-<left> and ctrl-<right> in insert mode and use only those. Everything more advanced (even in paredit) confuses me to no end 🙂


I find most of the sexp libs infuriating for the same reason. I don’t like being surprised by that. For example, if i want to close a parens and accidentally type a square bracket, I can’t delete the square bracket and then type a close paren because deleting the close bracket deletes the opening paren!


I use emacs mostly for lisp now, and similar to orestis I have disabled most everything except for ‘move sexp within sexp’ and ‘barf/spit’


Thankfully vim allows me to drop out of insert mode and delete whatever I damn please 🙂 Please the generic dab or with vim-surround dsb work nicely with lisps.

Noah Bogart13:05:04

vim-sexp is tough, but sexp-for-regular-people is nice

Noah Bogart13:05:27

>) and <) are very helpful for moving enclosing brackets


can someone who uses vim-sexp with or without the tpope mappings tell me how to have the same effect that parinfer has on indentation? move the block left or right, changing only indentation and moving the parens such that they are balanced? What is weird that everyone talks about structural editing that it's about never getting the code into an incorrect state, but it's actually very easy to achieve that


>)=ie with tpope <M-S-l>=ie without tpope. Alternatively use >ie instead of =ie dependent on what you're after.

(ns foo)
From cursor anywhere in (ns foo)


I never get the code into a correct state when using vim-sexp.


you mean incorrect I guess?


I have incorrect when I move code around, especially when I move it into some temporary place, or when I copy it from github, same repo, but doing a git checkout --patch is not always the easiest


I need to try these shortcuts, but first read them again from scratch how they are composed. On an unrelated note, it does seem everything got a bit more complicated, like adding a new line in a list was just pressing o at the end of the previous list and the parens were moved automatically, but now I have to >I and <enter>


so five keys instead of one


Oops, I did mean incorrect yes 😄


Parinfer is great for certain kinds of operation 🙂 I really like the vim-sexp model as it gives me more re-use & power though. There's just different properties to each of them really.


What I started to realize is just how many steps I have to step back before I can use these mappings, lots of things that I just do automatically relied on the editor formatting my code from incorrect to correct, or giving me an error where it was incorrect. Before cljs I wrote mostly js and I used to just copy paste code and data between files, often commenting out several lines and only after a bunch of these changes to a file started I fixing up the syntax errors.


Now I have to think first about how to format the stuff before I move it into the file. I can see the benefits, but ultimately I like the relaxed paradigm more.


I don't have these problems because I copy using vim-sexp, which means my copies are perfectly valid syntax too. e.g. yaf is a common operation for me.


Sure, that is the case when the place you copy from is well formatted. I am working on the frontend, and no one else uses clojure around me. So the places I copy from atm. are rarely well formatted S-expressions or opened in vim at all. : )


I don't really understand your use case, it sounds like you're not copying clojure code.


that's what I said

Noah Bogart18:05:46

i don't think either handles indentation like that. i usually use the keybinds i mentioned to push the surrouding parenthesis to sexp before or after a given block, and then =iP to reindent the whole paragraph


I see, that would be a nice thing to not lose


FWIW, I use parinfer AND vim-sexp with the tpope mappings, and it works well 🙂


The 3 plugins are complementary.


what do you do when parinfer ruins your undo?


I had that problem a long time ago, but haven't noticed it anytime recently. I think (and have read that) they've fixed it. I'm also in the habit of leaning heavily on git when trying experiments, e.g. I'll make a branch to try out an idea, and if it doesn't work out I just switch back to the branch I was on before. I rarely need to undo more than a few times in a row.


They haven't fixed it for me, this is why I am learning these other mappings. Every couple of hours at least I had to turn parinfer off, do the undo/redo i wanted, then turn it back on. Otherwise it just kept repeating a no-op.


I also encounter the undo-bug often. Which is keeping me from using parinfer at the moment


same, I would use it happily, but I suspect something I do is very unexpected, or maybe some conflict with another plugin


btw =- will reindent the entire top level form, saves some clicks / shift key chording


what do you do when pressing -= messes up indentation?


I've never gotten the order wrong, strangely


wait - do you mean that you don't like the rules auto-indent uses?


my solution is to just use code layouts that auto indent agrees with (all -= does is move one line up, then wait for a movement command for indentation scope, so I misunderstood you at first) anyway, this was a reply to the comment above about using =iP which does the same thing with more awkward keypresses


should have put it in that thread actually


I have a hard grudge against parinfer after a work scenario where one coworker would check in badly indented code, and another would let intellij move all the parens to match the bad indentation and check that in


anyway, it sounds like you don't want text objects for sexps etc. and you just want parinfer, I'm surprised if nobody ever made parinfer for vim


> wait - do you mean that you don't like the rules auto-indent uses? definitely not that, no, what I mean is that no one would like the result, lines get indented incorrectly, this never happens to you? My setup must be faulty then.


as long as I indent the whole form, I've never had an issue (though my preferences might be different from others and I'm sure there's corner cases I avoid by restricting where I put line breaks)


I think I found the culprit, and it was my setup, I had another extension enabled that auto-changed shiftwidth, because I used to edit js files, and for some reason in certain cljs files it set it to 10... so when I was indenting, it ended up all weird and unreasonable. Sorry for faulting sexp for this, clearly it had nothing to do with it.


I removed the plugin and now I started using == because easy to remember, I have no idea how indentation works yet, but it makes the code follow the current parens, so I can change the parens then run == again and it kinda works.


I don't know your setup, but for me == only looks at the line directly above, and when I'm doing things like renesting forms I need =- which fixes the entire top level form


I think it was just easier to remember ==, I will try to use =i