On Feb 17, 2011, at 10:05 AM, DK wrote: > This should be straight forward but I can't readily find an answer: > > If I have a search: > > :%s/search_text.*more_text/replace_text/gc > > How can I access the matched text (note above the regex in the > middle). > > For example I would want to do something like (coming from TextMate I > could use the $0 value to access the match and use it in the replace):
Use & or \0 for the whole matched text and \1 for the first group matched inside \(\), \2... see :help sub-replace-special > > :%s/search_text.*more_text/replace_text$0more_replace_text/gc > > Where $0 would be the match and I would be appending to it. > > -- > 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 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