I have some text in a Vim variable ‘myvar’. I would like to use this

variable in a “:s” substitute command to replace a text ‘mytext’. How do I do this? You can use the ‘execute’ command to evaluate the variable:

    :execute '%s/mytext/' . myvar . '/'



    :%s/mytext/\=myvar/

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