Search in selected text
When refactoring it would be helpful to be able to highlight some text in a file and only search for occurrences in that selection. Also a nice feature would be to search in scopes / methods - so the same thing, just inside methods. This also helps if you have a very long file and you don't know the code. Sometimes when you search, PHPStorm jumps to completely other part of that file.
Please sign in to leave a comment.
Hi there,
Sure -- use it. It is available and nothing should be stopping you from using it.
https://www.jetbrains.com/help/phpstorm/finding-and-replacing-text-in-file.html#findInSelection
Sadly it's not possible/available -- you have to use selection for this.
Have you tried using the actual Refactoring menu? (sorry, no idea on how well you know PhpStorm features, sounds like you are a new user to this IDE) https://www.jetbrains.com/help/phpstorm/refactoring-source-code.html
Although there are "Scopes" -- but it's for Find/Replace in Files (global search, not current file only) and other file name/path based operations.
https://www.jetbrains.com/help/phpstorm/configuring-scopes-and-file-colors.html , https://www.jetbrains.com/help/phpstorm/2021.2/finding-and-replacing-text-in-project.html
Yes, sorry about that... I already knew this feature. I actually wanted an easy way to select all text in a method or a search in method.
And yes, I already use the refactor menu, but when you analyse, you sometimes need to follow the variables. Yes you could use break points instead but I like the other approach.
You can use "Edit | Extend Selection" to rapidly extend selection stopping at the certain "code borders".
https://www.jetbrains.com/help/phpstorm/working-with-source-code.html#editor_code_selection
Not really sure what you meant to say here, sorry.
Anyway: sounds like Multiple Carets can be useful here (to edit the same text in multiple places in a file at once). Or maybe even "Code | Aanalyze Code | Data Flow to/from here..."
Thanks, I will try the extend selection feature. Haven't tried that yet.
Extend selection is exactly what I wanted, thank you :)