From the course: Learning Vim
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.
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
(Locked)
Delete text1m 16s
-
(Locked)
Challenge: Delete sentence5s
-
(Locked)
Solution: Delete sentence15s
-
Copy and paste2m 2s
-
(Locked)
Challenge: Copy and paste6s
-
(Locked)
Solution: Copy and paste15s
-
(Locked)
Change text1m 25s
-
(Locked)
Challenge: Change text13s
-
(Locked)
Solution: Change text16s
-
(Locked)
Visual selection1m 55s
-
(Locked)
Challenge: Use visual selection6s
-
(Locked)
Solution: Use visual selection21s
-
(Locked)
Registers2m 36s
-
(Locked)
Challenge: Use registers11s
-
(Locked)
Solution: Use registers46s
-
Replace text1m 7s
-
(Locked)
-
-
-
-
-