Last Updated: February 25, 2016
· akhilravidas

Substitute last search pattern


When the substitute command :s is given no argument, it takes the last search pattern as the match string. This is really helpful when working with complex substitute patterns like regexes or when combined with * (searches for word under the cursor)

For example:

# Find all references of string or map

 # Add std:: prefix to the search terms

Source file:

string a;
map<string, string> b;

End result:

std::string a;
std::map<std::string, std::string> b;
Say Thanks
Filed Under

Awesome Job

A3e45f3a cade 11e7 83bc 71c9546a2749
Systems Engineer
Fulton, Maryland or Remote
Full Time