Is this case fitting search/replace possible?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Is this case fitting search/replace possible?

tuxic
Hi,

I want to search and replace in the following manner:

Find the word. whjch should be replaced in a case insensitive manner.
But:
Replace the word by preserving the case.

Example:
Given world is "search" which shoyld be replaced by "replace"

When finding     replace it with
"Search"         "Replace"
"SEARCH"         "REPLACSE"
"search"         "replace"
"SeArCh"         "RePlAce"
and so on...

Is it possible without any further interaction?

Thanks a lot in advance!
Cheers!
Meino

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is this case fitting search/replace possible?

Benjamin Fritz
On Saturday, April 21, 2018 at 12:04:12 PM UTC-5, [hidden email] wrote:

> Hi,
>
> I want to search and replace in the following manner:
>
> Find the word. whjch should be replaced in a case insensitive manner.
> But:
> Replace the word by preserving the case.
>
> Example:
> Given world is "search" which shoyld be replaced by "replace"
>
> When finding     replace it with
> "Search"         "Replace"
> "SEARCH"         "REPLACSE"
> "search"         "replace"
> "SeArCh"         "RePlAce"
> and so on...
>
> Is it possible without any further interaction?
>
> Thanks a lot in advance!
> Cheers!
> Meino
I think the "abolish" plugin *may* provide what you want. At least, for some of your cases.

https://github.com/tpope/vim-abolish

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Is this case fitting search/replace possible?

David Woodfall
In reply to this post by tuxic
On Saturday 21 April 2018 19:04,
[hidden email] <[hidden email]> put forth the proposition:

>Hi,
>
>I want to search and replace in the following manner:
>
>Find the word. whjch should be replaced in a case insensitive manner.
>But:
>Replace the word by preserving the case.
>
>Example:
>Given world is "search" which shoyld be replaced by "replace"
>
>When finding     replace it with
>"Search"         "Replace"
>"SEARCH"         "REPLACSE"
>"search"         "replace"
>"SeArCh"         "RePlAce"
>and so on...
>
>Is it possible without any further interaction?
>
>Thanks a lot in advance!
>Cheers!
>Meino

If I understand you correctly, this is already done by

:set ignorecase

The replace string will still be case sensitive, even though the
search string isn't.

-Dave

--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.