Substituting text 'Edit1' by lines n1 to n2
Dear Linux Questions,
I am using VIM.
I have placed at various locations in my file a line 'INSERT1' to denote where I wish to add text, which is usually many lines of existing text in the same file.
I wish to copy specified lines n1 to n2 of my file into some sort of buffer, and then replace every occurrence of text 'Insert1' in the same file by the lines n1 to n2. Ideally in one operation.
I am familiar with the simple substitution command of type :s n1, n2 /text1/text2/g but of course rather than specify 'text1', I wish to use specified line numbers.
I have the idea of some sort of SED command, but at this point my knowledge breaks down and I know LQ must have many members who have met this problem before.
Any help would be very gratefully received.
Postscript. None of my simple Unix books mentions any limits on the length of text one can have when using the substitution command :s n1, n2 /text1/text2/g and yet every system has limits.
With best wishes,
Nick Edwards
24 March 2009 17:10
|