3 ms·
First impressions with this editor are very good. One thing I'm not 100% sure how to do is substituions with references so if I want to change the all the str
by GhotiFish 11y ago
First impressions with this editor are very good.
One thing I'm not 100% sure how to do is substituions with references
so if I want to change the all the strings "foo(5, bar)" to "baz(bar).foo(5)"
with 5 and bar being arbitrary strings. How could I do that? In vim I would use a regex expression and refer to matching sections with "%s/foo(\([^,]+\), \([^)]+\))/baz(\2).foo(\1)/gc". In Kakoune it seems I might have to do some multiselect shenanigans, the regex has better escaping for my taste, but I can't match on specific selections. So I can't shuffle them arbitrarily.
I looked through the vim golf challenges and couldn't find Kakoune doing an operation like this.
mawww, do you have some screencasts of you using this editor? I would be nice to have some live demonstrations showing off useful and common usage patterns for it.
- mawww 11y agoHello, If you get your selections through a regex, you will have access to capture groups in registers 0..9 (which will store the correct match for each selections), so to do the change you wanted, you'll type (in normal mode, no ':'): %sfoo\(([^,]+), ([^)]+)\)<ret> # select whole buffer, then select all regex matches cbaz(<c-r>2).foo(<c-r>1)<esc> # enter insert mode, <c-r> recalls a register I have been meaning to do a screencast at some point, or maybe I could do a twitch Q/A session.