Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Notepad++: Multiple words search in a file (may be in different lines)?

How can we perform multiple search for multiple words and the line containing them. These words can be in same or different lines. For example:

1.The CAT goes up and down the ROAD.
2. The DOG goes up and down the CITY.
3. The HORSE goes up and down the TOWN.
4. The DONKEY goes up and down the TOWN.

Now, I wish to do a search for the lines containing CAT and TOWN in one shot. So, I would get the output as line 1, 3, 4 in sequence. That would be the same way we do in Unix (more file | egrep "CAT|TOWN").

How can we do it in Notepad++??

like image 370
unirock Avatar asked Mar 31 '12 22:03

unirock


People also ask

How do I search for a line in notepad?

Finding a Line in Notepad To go to a specific line, click "Edit" and select "Go To" to display the Go To Line dialog. Type the line number into the field and click "Go To" to find the line. The blinking cursor is positioned at the beginning of the specified line.


4 Answers

You need a new version of notepad++. Looks like old versions don't support |.

Note: egrep "CAT|TOWN" will search for lines containing CATOWN. (CAT)|(TOWN) is the proper or extension (matching 1,3,4). Strangely you wrote and which is btw (CAT.*TOWN)|(TOWN.*CAT)

like image 58
Karoly Horvath Avatar answered Dec 25 '22 04:12

Karoly Horvath


<shameless-plug>

Search+ is a notepad++ plugin that does exactly this. You can download it from here and install it following the steps mentioned here

Feel free to post any issues/suggestions here.

</shameless-plug>

like image 44
Amarghosh Avatar answered Dec 25 '22 05:12

Amarghosh


Possible solution

  1. In Notepad++ , click search menu, the click Find
  2. in FIND WHAT : enter this ==> cat|town
  3. Select REGULAR EXPRESSION radiobutton
  4. click FIND IN CURRENT DOCUMENT

Screenshot

like image 21
miteshB666 Avatar answered Dec 25 '22 05:12

miteshB666


If you are using Notepad++ editor (like the tag of the question suggests), you can use the great "Find in Files" functionality.

Go to SearchFind in Files (Ctrl+Shift+F for the keyboard addicted) and enter:

  • Find What = (cat|town)

  • Filters = *.txt

  • Directory = enter the path of the directory you want to search in. You can check Follow current doc. to have the path of the current file to be filled.

  • Search mode = Regular Expression

like image 34
Houssine Oulhaj Avatar answered Dec 25 '22 04:12

Houssine Oulhaj