I have a config file that have placeholder PKG, in workflow, I need to replace this PKG with a string but typing :%s/blah/blah/g cost time.

I need a quick map key that asks for a string to replace then replace all PKG with that string.

Can vim do that? :)

1 Answer 1


Something like this:

nnoremap <KEY> :%s/PKG//g<Left><Left>

It populates the command line with :%s/PKG//g with the cursor between //. You can then simply type the new string and Enter

  • I just need that, a wrapper would overkill. Aug 16, 2018 at 12:13
  • May want to add :keeppatterns to avoid adding /PKG/ to the search history. See :h :keeppatterns Aug 16, 2018 at 14:07

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.