"Tim Chase" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] : > While editing a file, I decide to rename "someIdentifier" to : > "someIdentifier_" - I will need to append the underscore to : > several (but usually not all) instances of the word. : : The typical way to do this would be something like : : :%s/\<someIdentifier\>/&_/g : : If you want confirmation, you can use : : :%s/\<someIdentifier\>/&_/gc
Ok. So a possible shortcut to type this could be: *:%s/<C-R>//&_/gc Then: yn to accept/reject substitutions. : > The same would happen if I want to rename "wonderfulFoo" to : > : > "wonderfulBar". I tend to type: *fFceBar<ESC> : : Similarly, one would do something like : : :%s/\<wonderfulFoo\>/wonderfulBar/g Makes sense. Yet I liked the alternative: : [...] For your second example, you have to do a : little tweaking, as you want to be 3 characters from the : end, you have to use : : /someIdentifier/e-2 Nice! Damn, I remember reading about this flag, but I failed to think of using it ! So here, the "find + replace end of word" can be typed as: */<C-R>//e-2<CR>ceBar<ESC> Then: n.n to accept/reject substitutions. [ snipped: examples of the power of :s/.../ ] I like the simplicity/predictability of "n.", especially when reworking a function/small block within a larger file. But I am not petrified by regular expressions either -- I have been doing some perl programming (though I really am a C++ veteran). After 8 months of vimming (I started with http://www.viemu.com/), it is time for me to get more fluent with Ex commands. Just let me first enjoy the /../e trick for a couple of weeks... : Hope this helps, It did ! Thanks a lot. [ Thank you Tony as well for the additional references and advice for multi-file substitutions. ] Kind regards, Ivan -- http://ivan.vecerina.com/ ____________________________________________________________________________________ TV dinner still cooling? Check out "Tonight's Picks" on Yahoo! TV. http://tv.yahoo.com/