Skip to content

Latest commit

 

History

History
22 lines (15 loc) · 477 Bytes

vim-regex-word-boundaries.md

File metadata and controls

22 lines (15 loc) · 477 Bytes

Vim Regex Word Boundaries

Today while writing a Vim regex to change every instance of it (ignoring larger matches like itemized), we stumbled upon Vim regex word boundary matching.

Given this file:

foo
foobar

The following Vim regex will match on both the first and second line:

:%s/foo/baz/g

But with word boundaries, we'll only match (and change) the first line, because only the first foo is a standalone word:

:%s/\<foo\>/baz/g