On 2 Jan 2014, at 18:46, Cássio Marques wrote:

> Try this:
> 
> :%s/\v\s\|\s(\d+)\s(\w+)\s/ | \1 | \2 /g
> 
> -- 
> Cássio Marques
> 
> On Thursday, January 2, 2014 at 4:39 PM, Barrie Stott wrote:
> 
>> I have a few hundred lines of the following form:
>> 
>> _x(MP188 | 103 God is our strength and refuge (Richard Bewes)
>> _x(0 | 110 In God will I trust, though my counsellors say (The Psalter, 1912)
>> _x(0 | 113 O Father you are sovereign in all the worlds you made (Margaret 
>> Clarkson)
>> 
>> I want to replace '103 God' by '103 | God' in the first line and '110 In' by 
>> '110 | In' in the second, etc.
>> 
>> Supposing the lines above to be 40-42, I was able to select the appropriate 
>> places in the lines with '/\d\s[A-Z]' and the spots became highlighted. 
>> However, I still want '3' for the digit and 'G' for the letter in the first 
>> substitution so I tried '40,42 s/(d)\s([A-Z])/\1 | \2/g' and it complained 
>> about '(d)\s([A-Z])' not being recognized.
>> 
>> I'm now beginning to think it cannot be done so if anyone can help I'd be 
>> most grateful.
>> 
>> It shouldn't be needed but, just in case, I'm on a Snow Leopard iMac.
>> 
>> Barrie.

Many thanks for this since at first glance it seems to work well. I now need to 
go through your solution so that I understand it. You were amazingly speedy in 
answering (10 minutes) so I apologize for my delay in replying.

No reply needed and I'm *really* grateful.

Barrie.

-- 
-- 
You received this message from the "vim_mac" 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_mac" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to vim_mac+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to