(Vim) Using regex with magic in search & substitute
- Search: Add
\v
right after/
, i.e./\v<PATTERN_TO_SEARCH>
, e.g.:/\vAGE: \d+ NAME
- Substitute: Add
\v
right after the search part, i.e.%s/\v<TARGET>/<REPLACEMENT>/<FLAGS>
, e.g. to replace whitespace between age value and “NAME”::%s/\vAGE: (\d+) NAME/AGE: \1\rNAME/g
Written on October 1, 2021