https://kotlinlang.org logo
#getting-started
Title
# getting-started
j

Joshua Akinsola

11/22/2021, 12:15 PM
Hi all, does anyone know how to search through code on Android studio simply like you can on VS code?
j

Joffrey

11/22/2021, 12:17 PM
I'm not familiar with VS code, what kind of search are you looking for? Single-file search? (Ctrl+F) Full-text search across the project/module/directory? (Ctrl+Shift+F) Find usages/go to declaration? (Ctrl+click or Ctrl+B) Structural search? (Edit > Find > Search structurally...) You should be able to discover all options from the
Edit > Find
menu
j

Joshua Akinsola

11/22/2021, 12:18 PM
VS code has a simple to use full-text search across the whole project
j

Joffrey

11/22/2021, 12:19 PM
Then you can do the same with Ctrl+Shift+F, which is the
Find in Files
action (on macOS it's Cmd+Shift+F I think)
m

MarkRS

11/22/2021, 12:34 PM
AS has "Find in Files" on the context menu in the project inspector. Really good, really fast. I don't know VS at all so is that what you want? You can ctrl-click on elements to go to their declarations and a host of other things too... Any good?
j

Joshua Akinsola

11/22/2021, 1:04 PM
Does that search the whole project though? Doesn't seem to for me
@MarkRS for the file inspector I see the one on the far right and that didn't search the whole project for me
j

Joffrey

11/22/2021, 1:22 PM
Once you open
Find in Files
(Ctrl+Shift+F), you have a tab selection. Make sure it's on `In Project`:
m

Michael Böiers

11/22/2021, 1:22 PM
^ (which is the default)
m

MarkRS

11/22/2021, 1:23 PM
@Joshua Akinsola, it's a context menu so it searches from the point you invoke it. As @Joffrey illustrates that means you can search the whole project, or part of it.
j

Joffrey

11/22/2021, 1:24 PM
^ (which is the default)
@Michael Böiers it depends on where your current selection is. If you have selected a folder in the project view, the window will open on the
Directory
tab by default
m

Michael Böiers

11/22/2021, 1:30 PM
Yes, once you’ve clicked a folder and then invoked the search, it’s in directory mode. But if you re-start the IDE, it will search the entire project.
j

Joshua Akinsola

11/22/2021, 1:35 PM
I'm using a mac and I don't get the same type of search box you do? (I'm using the Artic fox version)
m

Michael Böiers

11/22/2021, 1:45 PM
^ That looks like the standard search in the editor (CMD+F) rather than the full search (CMD+SHIFT+F).
1
k

kqr

11/22/2021, 1:58 PM
maybe shift+shift is what you are looking for a.k.a. search everywhere
j

Joffrey

11/22/2021, 2:02 PM
Yes that is also a way, but I think @Joshua Akinsola really is looking for full text search of project files, not search among actions etc. on top of the full text search (which might be undesirably wide). But judging by the last screenshot it looks like he's just using Cmd+F instead of Cmd+Shift+F, which is the essence of the problem here
m

MarkRS

11/22/2021, 2:27 PM
It works just the same on a Mac @Joshua Akinsola, so perhaps you're not accessing it from the project viewer, the one (coincidentally) shown in the top left of pavi2410's message below yours
j

Joshua Akinsola

11/22/2021, 4:20 PM
The Cmd+Shift+F is what i'm looking for. Thanks!
2 Views