How to replace the word under the cursor (say: junk) with “foojunkbar” in Vim? There are several ways to do this. If the word is

the first such word on the line, use the following command:

    :exe "s/".expand("")."/foo&bar/"

To match specifically you could use a more complex substitution like this:

    :exe 's/\<'.expand("").'\%>'.(col(".")-1).'c\>/foo&bar/'

You can also use the command: ciwfoo<C-R>“bar<Esc>

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