I would like to remove all the newline character that occurs after a partiular string and replace it with a tab space. Say for instance my sample.txt is as follows
Mmm. not sure this fits your requirements, but I'd do this in vim:
:g/^foo$/join
Or, if foo could be anywhere on a line:
:g/foo$/join
Of course, :%s/foo\n/foo\t/g will do nicely too
:%s/foo\n/foo\t/g