2

Scenario: I've got 4 files in my Quickfix list and I want to add a new line, "status": "not started", onto line 5 of each of them.

I tried this:

cfdo norm 5GO"status": "not started",

Which I thought would work on each file, move to line 5, O adds an empty line, and then I'm adding my text. But this doesn't work.

What am I doing wrong, and is there a better way to do this?

2
  • 3
    can you try :cfdo :call append(4, '"status": "not started"')? Sep 6 at 12:06
  • 3
    Try escaping the double quotes. Sometimes vims command line thinks they are comments
    – D. Ben Knoble
    Sep 6 at 12:17
2

Thanks to the commenters there are two decent options here.

Regarding the path I started on, as @D. Ben Knoble intimated, the escaping was important but I used singles around the doubles instead.

I also used 'execute' so I could wrap the whole thing as a string. Not sure if that was needed or not?

So

:cfdo execute 'norm 5GO"status": "not started",' | update

worked, as did @Christian's

:cfdo :call append(4, '"status": "not started"')
1
  • Please accept your answer if it solved your problem to resolve the question.
    – D. Ben Knoble
    Oct 5 at 14:19

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.