You might have faced the scenario in which you need to change the same text across several documents or add something with relative to some text. Many editors do have search and replace functionality but Notepad ++ offers the functionality to search and replace in all opened documents and moreover one needs to use them smartly in order to work smartly else their potential goes untapped.
For example
We have 50 files under a directory in which a word was misspelled or you need to change the name of some entity in the code, then manually changing them in each of the files is surely not the way. What we can do is to use Notepad++ to replace a text with another text in files contained in that directory. We can also set filters to look up in certain extension files only and it supports wildcards so its pretty much a powerful filter.
Hit Ctrl + F, select the third tab Find in files and fill options as per your need. As shown in the screenshot, it will look under deep folder specified for all types of files and replace the occurrence of text fame by ashfame. You can limit the search to say PHP files by setting the filter to *.php or limit the search to txt files starting with name a by setting the filter to a*.txt and click Replace in Files.
A bit of caution is that hollyfame and dollyfame will be changed to hollyashfame and dollyashfame respectively. If you want to avoid this and only need to match whole words only, then make sure you check the box which says Match whole word only.
Other options available are
- Match case so that exact case of fame is matched and Fame or FAME are not matched.
- Directory search includes lookup in all sub-folders and hidden folders
- Advance users can use extended and regular expression search modes.
I would like to highlight the fact that proper attention should be taken care of such powerful replacements else things may go wrong without any notice and it will become hard to revert them at a later date.
I would suggest first viewing all the results by clicking Find All first and then clicking Replace in Files after taking a look at the search results.
I hope that this share was useful to you. This will take some practice and time when you would be able to use it with ease and do powerful replacements quickly and efficiently. What do you think?
Comments
5 responses to “Search and Replace text in multiple documents quickly”
I’ve been using this tip from quite a long time. I am dead sure not many are aware of this feature. When the site was attacked, I couldn’t find the injected code in the theme files manually. Luckily, I found this option and did a broader search.. Amazing feature from Notepad++. Dead simple and does the job..
Just tweeted so people would know about this ๐
Yes its awesome and is generally limited by the limit of what user can think of exploiting it to needs. Thanks for the tweet! ๐
Notepad++ rocks! Why didnt Microsoft make it?
May be they didn’t work in ASAP mode. :/
Great little tip. Had a few good uses for this. I also agree that not many people know about this feature. Love notepad++