Fork me on GitHub
#spacemacs
<
2017-09-02
>
kasuko00:09:50

Is it possible to run ex commands via a kbd-macro? I have some quoted strings and in the quoted string I have to replace all / with _, all + with - and all = with nothing. I was hoping to do a kbd macro that would visual select inside the quotation and then run the 3 ex commands to substitute but it doesn’t seem to be working.

kasuko00:09:38

eg. "some/things+other-things=" which needs to become "some_things-other-things"

kasuko00:09:29

note: the rest of the string is essentially random so no simple search and replace will work

jeff.terrell03:09:41

@kasuko - This sounds like a frustration I've hit before. It seems that macros in evil-mode are not nearly as robust as they are in Vim. I don't know the answer to your question, but I'd guess the answer is no. 😞

ag22:09:57

@jeff.terrell > It seems that macros in evil-mode are not nearly as robust as they are in Vim I don't think that's true. Macros get recorded as keyboard macros in emacs-lisp, you can make some incredible shit with them

ag22:09:08

try M-x kmacro-edit-macro after defining one

ag22:09:14

@kasuko I was able to record a macro that finds next occurrence of ", then selects everything in it - vi", then applies string replace using ex command - e.g. :'<,'>s/foo/bar/g

kasuko23:09:23

@ag would you be able to send me that macro? I wasn’t able to do it either by using : or even M-x evil-ex

kasuko23:09:22

I was even experimenting just trying to get a keyboard macro that run the :buffers ex command and I couldn’t

ag22:09:36

AFAIK keyboard macros defined by evil-record-macro are localized to a current buffer

ag22:09:25

maybe try Emacs's native keyboard macros C-x (

ag22:09:27

¯\(ツ)

kasuko14:09:28

Hmm, I was trying C-x ( … I will look into evil-record-macro thanks!

eggsyntax23:09:49

I'll second @ag on this one. I've never observed anything that I was able to do in vim with a keyboard macro but unable to do in spacemacs.