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>

Comments (1)


Pepsh Pepshinsky

Let’s see you to :help viminfo-file-name (option -i) :set viminfofile=NONE


Speak Your Mind