From the course: Learning Vim

Replace text - vi Tutorial

From the course: Learning Vim

Start my 1-month free trial

Replace text

- [Instructor] Open new.txt, vim new.txt. Say you'd like to replace you with they. Here's how you do it. Column S replace you with they and enter. As you can see, only the first occurrence was replaced. The second you was not replaced. If you'd like to replace all, you need to add the G switch to column S. Undo with U. And now, column S/you/they and slash again and g for global replacement search, enter. And now you see that both of the occurrences of you was replaces with they. Sometimes you'd like to confirm a change. This can be done with the C flag to column S. Let's undo again with U. And now column S slash you with they, global and confirm and enter. And now Vim will ask, would you like to change this one, I'll say no to the first, and yes to the second.

Contents