How do I reuse the last used search pattern in a “:substitute”

command? To reuse the last used search pattern in a “:substitute” command, don’t specify a new search pattern:

    :s/pattern/newtext/

    :s//sometext/

In the second “:s” command, as a search pattern is not specified, the pattern specified in the first “:s” command ‘pattern’ will be used. If you want to change the search pattern but repeat the substitution pattern you can use the special right hand side, you can use the tilde character:

    :s/newpattern/~/

Read free Software Algorithms and Computer Science Books by CodeAhoy Learn.

Introduction to Recursion and Backtracking

Sorting Algorithms

Introduction to C Programming Language

And More...

Speak Your Mind