in reply to (OT) Regular Expression

Though many Monks use vi, SOPW is not the appropriate place for a question strictly about vi.

If this were a perl question... and if your output illustration reflects your actual desire ("# 1 aba baba Cheers" does not match "how can i write regular exp to add new line in between # and 1."):

#!/usr/bin/perl use strict; use warnings; # 800208 my $test; while ( <DATA> ) { $test = $_; if ( $test =~ /#1 aba baba/ ) { chomp $test; print "$test Cheers\n"; } else { print "$test"; } } __DATA__ #1 aba baba #1 bsdb dbbsd #1 sdh hsds #1 aba baba #2 aba baba