[Qt-creator] Search and replace behavior with respect to case in editor

Harri Pasanen harri at mpaja.com
Fri Nov 30 16:04:16 CET 2012


On 11/30/2012 03:43 PM, Typz wrote:
> +1
>
> I started implementing something like this some time, but could not 
> get it complete due to regexp.
> This was limited to the following use cases:
>       - All upper-case match is replaced with the upper-case replace text;
>       - All lower-case match is replaced with the lower-case replace text;
>       - Capitalized match is replace with the capitalized text;
>       - Otherwise, use the provided replace text directly.
>
> Implementing the 'normal' case is easy, but I had a few issues:
>       - I could not find a simple way to make it work for regexp

I very seldom use regexp replacements, so for me it would be ok if it 
does not cover regexp replacements.

>       - I struggled with the UI to enable this feature: it is easy to 
> add an extra icon/menu in the search box, but this is not logical (as 
> it does not affect search)... Also, it seemed better to have the 
> option in the search result widget, but this did not work.
>

How about just adding a global setting (checkbox) to 
Tools->Options->Text Editor->Behavior pane?

Something like:

            Misc                     (new section under "Typing")

"Search and replace follows case [x]"


> I'll try to clean this up and provide a patch against master, for 
> people to try it.
>

I'll be happy to try it.

Harri



> Best regards,
> -- 
> Francois
>
>
> On Fri, Nov 30, 2012 at 2:01 PM, Cristian Tibirna <tibirna at kde.org 
> <mailto:tibirna at kde.org>> wrote:
>
>     On Friday 30 November 2012 12:23:53 Harri Pasanen wrote:
>     > It would be cool if search and replace would preserve case, in
>     the same
>     > way as Emacs does.
>     >
>     > So
>     >
>     > Search:  testpad
>     > Replace: numpad
>     >
>     > would produce these replacements:
>     >
>     > testpad -> numpad
>     > TESTPAD -> NUMPAD
>     > Testpad  -> Numpad
>
>     +1
>
>     >
>     >
>     > Bonus points for exceeding Emacs AI in the following cases:
>     >
>     > TestPad -> NumPad    (emacs gives Numpad)
>     > testPad  -> numPad    (emacs gives numpad)
>
>     +100
>
>     To be noticed that this can be done (in a limited way) with
>     regexps, but
>     having the regular s&r do this automatically is something I had
>     taken for
>     granted with XEmacs and would be a nice (and rather powerful) tool
>     to have.
>
>     Brownie points to Harri for gathering up the energy to write this
>     (I had
>     noticed it since a few years already but never pushed myself all
>     the way
>     through to writing here or in bugreports.qt-project about it).
>
>     --
>     Cristian Tibirna
>     KDE developer .. tibirna at kde.org <mailto:tibirna at kde.org> ..
>     http://www.kde.org
>
>     _______________________________________________
>     Qt-creator mailing list
>     Qt-creator at qt-project.org <mailto:Qt-creator at qt-project.org>
>     http://lists.qt-project.org/mailman/listinfo/qt-creator
>
>
>
>
> _______________________________________________
> Qt-creator mailing list
> Qt-creator at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/qt-creator




More information about the Qt-creator mailing list