How to Replace a VIM String With a Wildcard


One of the nice features of the VIM text editor is the powerful set of editing commands that a user has at his fingertips after he passes the initial learning curve of the system. Naturally, like every other text editor, VIM can search and replace strings of text, but VIM can also include wildcards in its search functions to fill in for information that may be different.

  • Press "Escape" to enter command mode.

  • Type the following:


    The "." character in VIM is a wildcard character that can fill in for any single character. The above line wold find any word that began with "w" and ended in "th," with any two characters in between, and replace it with the word "wrath."

  • Press "i" to return to edit mode.

Tips & Warnings

  • You can specify characters that can be used in the unknown regions by replacing the "." with the desired letters in square brackets. For example: "w[ie]t" would match both "wit" and "wet."


Promoted By Zergnet


You May Also Like

Related Searches

Is DIY in your DNA? Become part of our maker community.
Submit Your Work!