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

47649Preserve case during search & replace?

Expand Messages
  • Paul Brinkley
    Feb 10 9:44 AM
    • 0 Attachment
      [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