dotplan

troubleshooting & performance analysis

  • Author: gary
  • Published: Feb 16th, 2007
  • Category: how-to
  • Comments: None

vi search & replace paths & filenames.

Tags: , ,

When doing search and replace in vi, there is no need to ‘escape’ forward slash characters ‘/’ when manipulating pathnames. Instead, simply change the character used to delimit the search terms to something other than ‘/’ directly within vi (no .exrc change needed).

e.g.

./.cpan/build/Archive-Tar-1.30./.cpan/build/Archive-Tar-1.30/bin./.cpan/build/Archive-Tar-1.30/bin/ptar./.cpan/build/Archive-Tar-1.30/bin/ptardiff./.cpan/build/Archive-Tar-1.30/blib./.cpan/build/Archive-Tar-1.30/blib/arch

Then use the string below which uses ‘?’ where usually a ‘/’ is used to separate and delimit the srearch & replace terms. In this example I am replacing …cpan/build… with …cpan/build/z/y/z…

:%s?cpan/build?cpan/build/z/y/z?

Which results in

./.cpan/build/x/y/z/Archive-Tar-1.30./.cpan/build/x/y/x/Archive-Tar-1.30/bin./.cpan/build/x/y/x/Archive-Tar-1.30/bin/ptar./.cpan/build/x/y/x/Archive-Tar-1.30/bin/ptardiff./.cpan/build/x/y/x/Archive-Tar-1.30/blib./.cpan/build/x/y/x/Archive-Tar-1.30/blib/arch

Tags: , ,

Leave a Reply

*

© 2009 dotplan. All Rights Reserved.

This blog is powered by Wordpress and Magatheme by Bryan Helmig.