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.

0
6 comments

Hi there,

When refactoring it would be helpful to be able to highlight some text in a file and only search for occurrences in that selection.

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

Also a nice feature would be to search in scopes / methods - so the same thing, just inside methods.

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

0

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.

0

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.

0

I actually want a easy way to select all text in a method

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

 

but when you analyse, you sometimes need to follow the variables. Yes you could use break points instead but I like the other approach.

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..."

0

Thanks, I will try the extend selection feature. Haven't tried that yet.

0

Extend selection is exactly what I wanted, thank you :)

0

Please sign in to leave a comment.