Find string in a list of files


#1

How do I search for a piece of text in all the files in a given directory and have the search results be the list of files that have that piece of text? In sublime or textpad this is the “Find in Files” function.


#2

Try ctrl-shift-F. You’ll get the find in project dialog


#3

If you don’t like the find in project that @mark_hahn suggested, you could always use grep in the command line. That does exactly what you want.


#4

If you are lucky enough to have a posix environment, which I don’t. (grin)


#5

StackOverflow to the rescue! Here are a bunch of alternatives for grep on Windows.


#6

Assuming you have Git installed, so you can simply use Git Bash to have grep (and many other goodies) on Windows.


#7

@mark_hahn, I find PowerShell to be rather nice on Windows. It’s totally different than the Unix stuff I’m used to, but it’s better integrated with Windows than the Unix stuff. PowerShell has the Select-String command (also known as sls).


#8

Thanks all. I did see “Find In Project” under the Find menu item, didn’t realise it would do what I wanted, I should have tried it before I posted. Now that I have looked at it, it seems limited to the ‘current’ directory, tho.

I’m on Windows but I do have git bash and am happy to use grep, I just happened to be editing a file when the requirement came up.

What little of Powershell I have seen I find rather too new and not worth the effort :slight_smile:


#9

“Find in project” searches in the project, and that may be the current directory or not. The idea is, you do atom /some/directory from a command prompt, and then that is the directory you see in the tree view on the left, and that is the directory that is searched by “Find in project”. It’s also the directory that is searched by cmd-T (ctrl-T?) for files, and so on.


#10

Good point, didn’t think along those lines. Tx


#11

This worked for me: Right-click on a folder in treeView and select SearchInFolder.


#12

I didnt know about this, this is a great feature!


#13

Thanks, it was exactly what I was looking for


#14

I really like the feature in PSPad where you can see the results in a file and being able to double-click the result jumping to the related line in the file.
Also works in multiple files.


#15

Thanks a lot. :slight_smile:


#16

We can do this by ctrl + shift + f

In the project name enter field, type projectname,*.js for searching only words in js files