spacemacs

Spacemacs docs: http://develop.spacemacs.org/doc/DOCUMENTATION.html http://develop.spacemacs.org/layers/+lang/clojure/README.html https://practicalli.github.io/spacemacs/
jumar 2020-12-22T11:51:02.233Z

What's the best way to replace certain characters in a String with new lines? I tried with the usual "vim-style" (https://stackoverflow.com/questions/71323/how-to-replace-a-character-by-a-newline-in-vim) replace but \r just produces ^M in the source buffer. E.g. I have a stacktrace as a single-line string and want to split it into multiple lines

a.clj: 25 b.clj: 58 b.clj: 365 d.clj: 51 java.lang.Exception: ...

# should become:
a.clj: 25
b.clj: 58
b.clj: 365
d.clj: 51
java.lang.Exception: ...
I tried

practicalli-john 2020-12-22T11:54:18.233400Z

I wonder if iedit or multiple cursors would be useful for this... Will check when back at a computer

jumar 2020-12-22T12:06:51.233600Z

I ended up using sed like this:

echo "a.clj: 25 b.clj: 58 b.clj: 365 d.clj: 51 java.lang.Exception: ..." | sed -E $'s/(: [0-9]+)/\1\\\n/g' | tee >(pbcopy)
Still would be useful to know how to do it in emacs.

practicalli-john 2020-12-22T12:25:24.233800Z

Using iedit: SPC v v with as many v's needed to select the region SPC n r to narrow to the region (so I can select spaces just from that region v on one of the spaces to select the space character as a pattern SPC s e to create iedit cursors on each space, n to jump to the next cursor and TAB to toggle the iedit cursor, removing every alternate cursor. i for insert mode and RET to create new lines ESC to leave insert mode, ESC to leave iedit mode It sounds a lot, but its very quick to do if used to using iedit and narrowing.

jumar 2020-12-22T12:33:51.234100Z

I didn't quite get the thing with n and TAB - couldn't make it work. I can split it that way with simply replacing every space but there can be 3(?) spaces in each row (one of them is ommited from the example so there are only two) I basically need to split on digits/regex, I think.

practicalli-john 2020-12-22T12:37:08.234300Z

Multiple cursors is simpler v to visually select the first space where you want to cut the line C-n to place a cursor and jump to the next space C-t to skip placing a cursor at that position and jump to the next space Then alternate C-t to skip a cursor at the space and C-n to place a cursor at the place i and RET when you have all the cursors needed

practicalli-john 2020-12-22T12:38:58.234500Z

If there is a varing number of spaces, simply C-t until you get to the place where a space should have a return charater and press C-n

practicalli-john 2020-12-22T12:40:56.234700Z

Oh and when finished, g r q to kill all the cursors and go back to just one.

spfeiffer 2020-12-22T13:36:12.235200Z

I did it with SPC SPC replace-string, then the character i want to replace, then C-q C-j as replacement. Most likely not the most elegant way, but did the trick.

spfeiffer 2020-12-22T13:37:29.235400Z

C-o instead of C-q C-j works, too.

practicalli-john 2020-12-22T15:50:15.235600Z

I created a quick video as an example of using iedit and multiple cursors https://youtu.be/SCEQtSSb7Tc I shoud do more of these and join them up into a little demo of these really useful tools

Gleb Posobin 2020-12-22T16:14:52.235800Z

Replacing with \n instead of \r works for me.

Gleb Posobin 2020-12-22T16:15:27.236Z

:s/;/\n/g