I recorded a macro, that has an enter in it ggd/{<CR>Gdd but of course is ^M. What I want to do is run this on a bunch of files from the commandline which I guess would be something like

ex +"normal ggd/{<CR>Gdd" +wq

but how do I put an actual enter where it should go?

1 Answer 1



ex +"exe \"normal! ggd/{\<CR>\"" +"normal! Gdd" +"wq"

Basically you need to use :execute where you can pass \<CR> inside a double-quoted string

UPD as suggested in comments:

ex +'exe "normal! ggd/{\<CR>"' +'$d' +wq

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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