On Monday, September 23, 2013 11:54:27 AM UTC-5, Andrew Long wrote: > > What I thought of was to use a global operation limited to the 'for' and the > matching 'repeat', and what I tried was this:- > > > > :/^\(\s\+\)for\s\+\(\a\k*\)\s\+to.*/,/^\1repeat/g/\2/s/\2/i/g > > > > Only I fell at the first hurdle because it fails to find the matching repeat > pattern. >
In Vim, you can only ever use a backreference in the search where it was created. You cannot re-use a backreference from an earlier search in a later search. Here you have 4 searches. You use two for a range, one for the :g command, and another for the :s command. Only backreferences defined in the search pattern for the :s command can be used in the search or replace pattern for that command. You cannot use backreferences from the line range searching. Only backreferences defined in the pattern for the :g command can be used later in that pattern, you cannot use backreferences from the line range searching. Only backreferences defined in the "to" line pattern can be used in that pattern, you cannot use the backreference from the "from" line. -- -- 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/groups/opt_out.
