Wednesday, March 2, 2011

search and replace with word list

Hi All,
I searched the docs/faq/archive etc and didn't find an answer to this question (but perhaps I'm not using the right keywords)

Suppose I have in one file several lines (could be 100s of such lines) like this:
..
<Folder><![CDATA[C:\work\sources\foo\bar\baz\MODULEX\lib]]></Folder>
..

Now in another file I have a list of words, in this instance separated by newlines, but could be changed to space/tab/comma/etc delimited.
The number of words equals the number of lines that match from the first file.

Now what I would like to do is to replace each occurrence of MODULEX in file1 with the corresponding word in file 2.

By corresponding I mean if the lines (from file 1) and the words (from file 2) were both well ordered sets then the match is determined by the index into the set, or in other words a one-to-one correspondence.

--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

No comments: