Here's a puzzler for someone. I need to change this
[datomic.api ...][wrapper.datomic.api ...]
to this
[datomic.api ...]
[wrapper.datomic.api ...]
in 217 different files. I tried helm-ag-edit
, but it didn't let me create newlines. Is there an easy way to do this in emacs?Don’t know about that package, but if you’re entering a newline try C-q C-j
, it should enter a newline.
But you can also do this, if you’re just replacing a ][
with ]\n[
:
M-x replace-regexp RET ][ RET ] C-q C-j[ RET
Nice, that would have been great for adding the newline. I ended up using sed
and then manually indenting each file. Thanks for the suggestion!
consult-git-grep + embark occur, then wgrep on the occur buffer
sed
? :-)
Yeah, something like this is my fallback. I was just hoping I wouldn't have to write code for it. I have to learn sed
over from scratch every time I use it. 🙂
I've never heard of these. I'll look into them. Thanks!
At least some ways of doing string search and replace in Emacs let you type Ctrl-Q Ctrl-J in the middle of a replacement string to mean a newline
well, anywhere in the replacement string I mean, not just the middle.
Ctrl-Q being an Emacs 'escape' character prefix kind of thing, and Ctrl-J being the ASCII code for a newline
I had to write a post-it note with the C-q C-j
thing as I never remembered it. @bmaddy other (I'd say preferable) approach is to get the cljstyle
binary and run it against the whole codebase.
I just tried the c-q c-j thing in helm-ag-edit. Sadly, the newline it adds doesn't make it to the actual edit, so the line just gets truncated. Good idea though and I'm really happy to have found that key combo! I've been trying to figure that out for years. 😂