October 2015
Intermediate to advanced
356 pages
7h 54m
English
| Tip 77 | Stake the Boundaries of a Word |
When defining a pattern, specifying where a word begins and ends can be useful. Vim’s word-delimiter items let us do that.
Some words, especially short ones, have a habit of showing up inside other words. For example, “the” appears inside “these,” “they,” “their,” and many other words besides. So if we search the following excerpt by running /the<CR>, we’ll find more matches than we may have bargained for:
| | the problem with these new recruits is that |
| | they don't keep their boots clean. |
If we specifically want to match “the” as a word rather than a fragment, we can use word boundary delimiters. In very magic searches, these are represented by the < and > symbols. So if we amended our search to /\v<the> ...