> <start of text>
> aaaa  xyz   60
> AAAA  xyz   80
> 
> bbb1  xyz   90
> ddd2  xyz   100
> <end of text>
> 
> I want to add a dollar to the number
> I do the following:
> - look for any number on the line and replace that number with it self 
> and add the dollar before.
> 
> :%s/[0-9]/$&
> 
> <start of text>
> aaaa  xyz   $60
> AAAA  xyz   $80
> 
> bbb$1  xyz   90    <not ok>
> ddd$2  xyz   100  <not ok>
> <end of text>
> 
> The first two lines are ok but the last two aren't.
> 
> How do I change the command that it replaces the numbers after the xyz code?

You can force the context to be "the beginning of a 'word'" with 
"\<" making your replacement (and changing "[0-9]" to "\d" which 
is a little more idiomatic)

   :%s/\<\d/$&

-tim



--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to