Loading ...
Sorry, an error occurred while loading the content.

47657RE: Preserve case during search & replace?

Expand Messages
  • David Fishburn
    Feb 10, 2004
      Look no further (and of course it has been done) :-)

      Michael Geddes wrote KeepCase.vim

      It is a script (not a plugin), so open it, type
      :so %

      Then try one of his examples, works great for me.


      > -----Original Message-----
      > From: Paul Brinkley [mailto:laugh@...]
      > Sent: Tuesday, February 10, 2004 12:44 PM
      > To: vim@...
      > Subject: Preserve case during search & replace?
      > [I searched all over the web for an answer to this problem,
      > including vim.org's Tips, Sourceforge, Google, and Google
      > Groups. I found one reference to it in comp.editors back in
      > 2001, unsolved. The thread title is "case-preserving replace
      > in vi[m]?".]
      > Basically, I'd like to replace (e.g.) "apple" with "banana"
      > everywhere in a block of text, but if "apple" happens to be
      > capitalized, it should be replaced with "Banana". In other
      > words, I'd like a handy way of doing
      > :s/Apple/Banana/g
      > :s/apple/banana/g
      > (assuming noignorecase) with one command.
      > I could probably slog my way through a script to do this, but
      > it strikes me as a fairly useful feature - would Vim be
      > likely to have this feature added since 2001?
      > TIA...
    • Show all 22 messages in this topic