0

I have a list such as follows

apple
banana
cherry

I am trying to write a macro that will get it in this format (I am writing a .yaml file)

  - "apple"
  - "banana"
  - "cherry"

I recorded my macro with qa and typed v}geI - "<Esc>v}geA"<Esc>, then stopped recording with q.

When I replayed my macro using @a my result was

 apple"
 banana"
 cherry"

so there is a single space where there should be - ". I even tried replaying my macro on the same chunk of code where I recorded it (after undoing it) and got the same results.

I've also included a screenshot of the macro view when I run :reg.

I'm using vim 1.21.5 on vscode.

Thanks in advance!

screenshot of macro view

2
  • 2
    Your macro seems needlessly complicated. Try to achieve what you want manually first, then record that keystrokes. I'd probably go with something like this: ^V}I- "^[^VGA^[^VG$A"^[ where ^V means Ctrl-V and ^[ means Esc.
    – klaus
    Oct 5 at 9:09
  • 2
    Could be a vscode bug.
    – D. Ben Knoble
    Oct 5 at 12:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.