a weird question that i can't seem to solve

i want to do a search and replace,

anything that says

%d, %3d, %13d

or anything like that i want to replace it with XXX I'm not sure how to deal with any arbitrary number of numbers in between % and d.. is there anyway i can do this? for even something absurd like


I have tried to go about something like


to try and solve it each case at a time but I figured there's a better way to do a search and replace.. Thanks in advance!

  • 2
    @JimStewart You should write that as an answer. Commented Sep 20, 2017 at 6:40
  • @JimStewart If you added it as an answer we could upvote it so you can start earning the rep you need to close it ;) (I mean literally just paste it in: it's concise, but it fully answers the question.)
    – Rich
    Commented Sep 20, 2017 at 20:11
  • @solobyy you might have a look here to familiarize yourself with some of things that vim regex can do.
    – Tumbler41
    Commented Sep 20, 2017 at 20:39

1 Answer 1


This will match any number of digits before the d:


\d matches any digit, * matches 0 or more times.

See :h pattern.txt for all things regex.

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.