texasflood
texasflood

Reputation: 1633

Vim search and replace based on surrounding text

How do I replace vector with std::vector if and only if vector is not already preceded by std::? I could maybe come up with a convoluted way of doing it but I want something simple.

Upvotes: 1

Views: 106

Answers (1)

Amit
Amit

Reputation: 20516

Using negative lookbehind. This will replace vector with std::vector if and only if vector is not already preceded by std::

:%s/\v(std::)@<!vector/std::vector/g

Upvotes: 4

Related Questions