The easiest way to do this is to do a search as usual using 'incsearch' to ensure that the pattern matches what you want. Once you have a nail, you can either
- Leave the search pattern in
:%s//bar/ . If there is no specified search pattern, the current value of the register / , which will be performed only by you. - Paste the search pattern into the command
:s using Ctrl + r / (see :help c_ctrl-r ) or Ctrl + r Ctrl + o / (if the search contains control characters such as ^H ). This is useful if you want to make some final adjustments to the template or if you want to have it in your command history so that you can reuse it even after doing another search.
source share