sponsor Vim development Vim logo Vim Book Ad

globalreplace.vim : Prompted global search and replace

 script karma  Rating 11/10, Downloaded by 632  Comments, bugs, improvements  Vim wiki

created by
Chris Rummel
 
script type
utility
 
description
Instead of typing %s/foo/bar/gc every time you want to search and replace in a file simply call this function and get prompted for the text to find and what to replace it with.

I looked for something like this, but didn't find it, hope it's useful (my first, and admittedly unimpressive script)

p.s.

You might want to tack "I" onto the regexp to make it case sensitive, so it'll look like this:
execute "%s/".l:find."/".l:replace."/gcI"
 
install details
Simply drop the script in your .vim/plugin directory

I mapped it as follows
map <Leader>gr :call MISC_GlobalReplace()<cr>
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
globalreplace.vim 0.1 2004-12-06 6.0 Chris Rummel Initial upload
ip used for rating: 18.225.11.98

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
Vim at Github