Bug 363222 - support on-the-fly case conversion in Search & Replace plugin
Summary: support on-the-fly case conversion in Search & Replace plugin
Status: RESOLVED FIXED
Alias: None
Product: kate
Classification: Applications
Component: search (show other bugs)
Version: unspecified
Platform: Compiled Sources Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: KWrite Developers
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2016-05-18 13:43 UTC by Patrick Roye
Modified: 2019-03-06 05:49 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Patrick Roye 2016-05-18 13:43:02 UTC
The standard replace dialog supports on-the-fly case conversion using \U and \L in the replace expression. For example. find: (a), replace: \U\1 will replace lowercase 'a' with uppercase 'A'. The Search & Replace plugin does not currently support this feature.

Reproducible: Always

Steps to Reproduce:
1. Open a file that contains lower-case text
2. Open the Search & Replace plugin
3. Search in: Current File
4. Enable Regular Expressions
5. Find: (.*)
6: Replace: \U\1
7: Press Search
8: Press Replace checked

Actual Results:  
\U is placed at the beginning of every line

Expected Results:  
Lowercase letters are replaced by uppercase letters. This can be tested using the same settings with the standard replace dialog.

Kate version 16.07.70 built from source on Windows using Visual Studio 2015.
Comment 1 Kåre Särs 2016-05-18 18:55:52 UTC
good idea!
Comment 2 Jonathan 2016-06-27 00:49:19 UTC
A related request, possibly different enough to make a entry, but let's start by putting it here.

I'd like to propose a 'smart case match' option for search-and-replace that would make the case in the replaced text match the case in the search text. The reason is that I often find myself having to repeat search-and-replace functions to cover the same word written in different case styles. For instance if I want to rename an object 'foo' to the name 'bar', I typically need to do some or all of the following:
'foo' -> 'bar'
'Foo' -> 'Bar'
'FOO' -> 'BAR"
and it seems that a single smart search-and-replace could do all three at once by taking note of the case specified in the search and replace boxes.
Comment 3 Kåre Särs 2016-06-27 07:29:29 UTC
Jonathan: The idea is not bad, but it would probably complicate the code quite much. 
How would you capitalize the following: 
foo -> baar
but how about:
FOO -> BAAr or FOO -> BAAR

And how do you convert all instances of Foo, foo, FOO and fOO to Foo? I think the replace needs to be case sensitive except if you have explicit \U, \L or \I.

Unfortunately I don't think this reaches very high on my priority list. Sorry :(

('\U\1' and friends is on my TODO)
Comment 4 Jonathan 2016-06-27 07:46:13 UTC
All it would have to do is three case-sensitive search-and-replace operations: 1. Exactly as the user entered; 2. Substituting both fields with lower case; 3. Substituting both fields with upper case. I can't see much sense in trying to be smarter than that.

Anyway I see that it is quite a different problem from the one you are setting out to solve, but I'm happy to write it myself and propose it as a patch. If no-one but me likes it I'll keep it as a personal fork, wouldn't be the first time. :)
Comment 5 Lothar 2019-02-23 09:25:15 UTC
Can this be closed?
Now is the mentioned \U available
Comment 6 Patrick Roye 2019-02-25 15:54:05 UTC
The feature does appear to be implemented now. I didn't do much testing, but I did get the expected behavior using the steps I submitted in the original request. I'm good with closing this issue. Thanks!