Hi Tim, I get as far as the following :sp input.txt :%s/$/\\|/ :%j!
:s/..$ doesn't work at my windows system I use: execute "normal! \<end>xx" Then it fails on 0y$ I get the error message E488: Trailing characters I also noticed that the <C-R> mapping in the last substitute command is already used in another plugin. Is there a workaround for? Rgds, Jeri On Fri, Apr 18, 2014 at 9:44 PM, Tim Chase <[email protected]> wrote: > On 2014-04-18 20:07, Jeri Raye wrote: > > FileNAME: INPUT.TXT > > Containing: > > +----------+ > > james > > quebec > > canada > > +----------+ > > > > > > :%s/<INPUT.TXT>/replace found word with same word but first letter > > in uppercase./g > > > > > > Example: > > james was in quebec. > > The city quebec is in canada. > > > > Becomes: > > James was in Quebec. > > The city Quebec is in Canada. > > You can transform your input file into a single command: > > vi data.txt > :sp input.txt " open your word-list in a new window > :%s/$/\\|/ " start transforming it into a regexp > :%j! " join each line together > :s/..$ " delete the "\|" from the end of the line > 0y$ " yank the newly-formed regexp > :wincmd w " flip back to the file you want to change > :%s/\c\<\(<c-r>0\)\>/\u&/g > " substitute across the entire file (":%s/") > " ignoring case ("\c") > " a word must start here to match ("\<") > " start the list of alternatives ("\(") > " use control+R followed by zero > " to include the word-list joined by \| > " that we yanked previously > " close the list of alternatives ("\)") > " ensure that the word ends here ("\>") > " and replace it with ("/") > " the next letter uppercased ("\u") > " the text we captured ("&") > " and do all replacements on the line ("/g") > > This assumes that your input list is all just whole words, no funky > regexp metachars (periods, backslashes, asterisks, or > open-square-brackets come to mind). > > -tim > > > > -- -- 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 --- You received this message because you are subscribed to the Google Groups "vim_use" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
