vi - search replace with command
To search for a string, and then perform a vi command :
:g/string/command
for instance:
:%g/endofline$/join
will search for the string "endofline$" and then append the next line to any line that matches.
Vim documentation: http://vimdoc.sourceforge.net/htmldoc/