Jonathan Polansky

A pretty good webpage.

vi find and replace with back reference

This is an example of how to use the vi find and replace functionality with a back reference. Hopefully this will make it easier for someone else to figure out how to do it than it was for me.

This particular find and replace command was used to convert a file of source and destination URLs. The file had one source and destination URL space separated per line. The below rule converted the text to valid Apache mod_rewrite RewriteRule rules suitable for loading into an Apache httpd configuration. Don’t forget to escape your source URLs!

:%s/^\(.*\)$/RewriteRule ^\1 [R=301,L]/g


Tagged as + Categorized as Tech

1 Comments

  1. Hi Thanq , it really helped me to use back references in vi

comment_type == "trackback" || $comment->comment_type == "pingback" || ereg("", $comment->comment_content) || ereg("", $comment->comment_content)) { ?>

Trackbacks & Pingbacks

  1. Sri

    Hi Thanq , it really helped me to use back references in vi

Leave a Reply