I have a file which looks like this:
file1
file2
file3
.
.
.
filen
I want to convert it to :
echo "file1"
cat file1
echo "file2"
cat file2
.
.
.
.
echo "filen"
cat filen
One way can be to have a for loop and read the content of original file and write modified content to another file , I did that and it worked. Is there any command to do the same in vim through :g or any other command?
Try this:
Explanation:
:%s/a/b/gmeans search whole file and replaceatob..*means match every thing in one line.\0means the matched thing.\rmeans the new line.