Please use the Apache issue tracking system for new NetBeans issues ( !!
Bug 80732 - Support Emacs style case sensitive find and replace
Support Emacs style case sensitive find and replace
Product: editor
Classification: Unclassified
Component: Search
All All
: P3 with 3 votes (vote)
: 7.1
Assigned To: Milutin Kristofic
: 80798 90387 117771 125144 199989 (view as bug list)
Depends on:
  Show dependency treegraph
Reported: 2006-07-20 15:34 UTC by _ sandipchitale
Modified: 2011-08-04 13:48 UTC (History)
2 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description _ sandipchitale 2006-07-20 15:34:28 UTC
Use case:

With the following code:

FooBar fooBar;
static final FooBar FOOBAR = ...;

and desire to modify the name of the Class and the variable it should be 
possible to do this in a single Find and Replace  by using:

find text:    foobar
replace text: mooBlah

should result in a code:

MooBlah mooBlah ;
static final MooBlah MOOBLAH = ...;

Notice how the case of the original Class name, variable and static final 
variable and the uppercase B in replacement text were used as hints to achieve 
the functionality.

This is supported by emacs and is described like this in the emacs manuals:


20.9.3 Replace Commands and Case
If the first argument of a replace command is all lower case, the command 
ignores case while searching for occurrences to replace—provided case-fold-
search is non-nil. If case-fold-search is set to nil, case is always 
significant in all searches. 

In addition, when the newstring argument is all or partly lower case, 
replacement commands try to preserve the case pattern of each occurrence. 
Thus, the command 

     M-x replace-string <RET> foo <RET> bar <RET>

replaces a lower case ‘foo’ with a lower case ‘bar’, an all-caps ‘FOO’ 
with ‘BAR’, and a capitalized ‘Foo’ with ‘Bar’. (These three alternatives—
lower case, all caps, and capitalized, are the only ones that replace-string 
can distinguish.) 

If upper-case letters are used in the replacement string, they remain upper 
case every time that text is inserted. If upper-case letters are used in the 
first argument, the second argument is always substituted exactly as given, 
with no case conversion. Likewise, if either case-replace or case-fold-search 
is set to nil, replacement is done without case conversion. 
Comment 1 _ sandipchitale 2006-07-22 19:15:49 UTC
Also see:
Comment 2 Vitezslav Stejskal 2008-01-23 09:56:09 UTC
*** Issue 80798 has been marked as a duplicate of this issue. ***
Comment 3 Vitezslav Stejskal 2008-01-23 09:56:20 UTC
*** Issue 90387 has been marked as a duplicate of this issue. ***
Comment 4 Vitezslav Stejskal 2008-01-23 09:57:42 UTC
*** Issue 117771 has been marked as a duplicate of this issue. ***
Comment 5 Vitezslav Stejskal 2008-01-23 09:58:05 UTC
*** Issue 125144 has been marked as a duplicate of this issue. ***
Comment 6 Vitezslav Stejskal 2008-01-23 09:59:39 UTC
Please see all the duplicates for different descriptions of the same usecase.
Comment 7 voidmain 2008-12-09 15:41:46 UTC
This definitely gets my vote. IntelliJ does this already. Very nice feature to have work manipulating large codebases.
Comment 8 Milutin Kristofic 2011-07-08 14:14:09 UTC
*** Bug 199989 has been marked as a duplicate of this bug. ***
Comment 9 _ gtzabari 2011-07-08 16:59:18 UTC
This gets my vote. Any chance of pushing this into version 7.1? On the face of it it sounds rather easy to implement.
Comment 10 Milutin Kristofic 2011-07-12 15:30:00 UTC
I will implement this for to nb 7.1
Comment 11 Milutin Kristofic 2011-08-01 16:05:10 UTC
I implemented preserve case to netbeans search and replace.

It has its own checkbox which is disabled if matchcase or regexp is selected. 

For example you search for foobar to replace by someElse

foobar -> someelse
FooBar -> SomeElse
fooBar -> someElse

Please notice upper case in someElse.

Hope you like it.
Comment 12 Quality Engineering 2011-08-04 13:48:00 UTC
Integrated into 'main-golden'
User: Milutin Kristofic <>
Log: #80732 - Support Emacs style case sensitive find and replace - preserve case in ctrl+h search and replace dialog

By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo