>> I've never saw a saw saw a saw >> I just want to replace the 2nd or 3rd "saw", Do you have any idea? > > Not beautiful solution to replace 3rd "saw" to "seen": > s/^\(.\{-}saw.\{-}saw.\{-}\)\(saw\)/\1seen/
Though not beautiful, it's easy to do, and even easier with the command-line window where you can paste the same regexp piece multiple times. You can yank the ".\{-}saw", and then paste it as many times as you need. I frequently do something similar with tab-delimited files, using something like s/^\%([^\t]*\t\)\{4}\zsvalue_in_col_5/replacement/ to search a given column (column-5 in this case), and do replacements at that given point. The above finds \{4} "non-tab stuff [^\t]* followed by a tab \t" matches grouped-but-not-tagged with \%(...), then starting at this location \zs, perform my actual value_in_col_5 -> replacement. -tim --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~---