When replacing words in text it may interesting to keep case of the new text like the case used in the old.
This is useful for word occuring at begging of sentences and in the middle.
With conventional replace one needs to make two case sentive replacements, one with first letter uppercase and a second with all letters lowercase.
Some heuristics could be:
- if the matching word is all lowercase, then the replaced word will be also.
- if only the first letter of the matching is uppercase, then
first letter of the replaced word will be uppercase.
- if all matching text is uppercase, so the replaced text will be all uppercase.
may I promote this feature request ?
It is one I would also raise, but it seems it was not noticed due to the age of this post.
To me, it would additionally make sence, to store previous search or replace values in a case sensitive way. When I first search for e.g. FOOBAR, and after that earch for foobar, my first value wont appear in the previous search value drop down any more. :/
Thanks in advance
I think the TextFX plugin allows intelligent replacement.
But it may be unstable with the unicode version of N++ !
- Download this plugin
- Put the NppTextFX.dll in plugin folder and restart N++
- Open a new file ( CTRL + N )
- Just type ONE line : " find Find FIND "
- Go back at the beginning of the file ( CTRL + Origin )
- Open the TextFX Find/Replace dialog :
Menu " Text FX " -> " TextFX Quick " -> " Find/Replace "
or use the shortcut " CTRL + R "
- Type " find " , without quotes, in the search box
in ANY case
- Type " Replace ", without quotes, in the replacement box
with the FIRST letter in UPPERCASE ( Important )
- Don't check the box " Match case "
- Check the box " Repl match case " ( Important )
- Click ONCE on the " Find " button to get the first word " find "
- Click on the " Replace Rest " button
=> The original line has been changed into
" replace Replace REPLACE "
Waoooooou.. ! , it did the job :)
In fact, the EXACT case typed, in the replacement box, will be
used, for the replacement, if the finded occurrence of the search
is NOT ALL lowercase or ALL uppercase !
If the finded occurrence is ALL lowercase, the replacement word is ALL lowercase
if the finded occurrence is ALL uppercase, the replacement word is ALL uppercase
I hope this can help you a little bit !
Many thanks, very helpfull explanation.
Sign up for the SourceForge newsletter:
You seem to have CSS turned off.
Please don't fill out this field.