October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 90 | Eyeball Each Substitution |
Finding all occurrences of a pattern and blindly replacing them with something else won’t always work. Sometimes we need to look at each match and decide if it should be substituted. The c flag modifies the :substitute command to make this possible.
Remember this example from Tip 5?
| | ...We're waiting for content before the site can go live... |
| | ...If you are content with this, let's go ahead with it... |
| | ...We'll launch as soon as we have the content... |
We couldn’t use find and replace to change “content” to “copy.” Instead, we used the Dot Formula to solve our problem. However, we could also have used the c flag on the substitute command:
| => | :%s/content/copy/gc |
The c flag ...