Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PHPStorm - Find and Replace Text in Selection?

Tags:

phpstorm

In most other editors, I can select a portion of the text I want to run find and replace on and then hit the ctrl + h combination. A screen pops up asking me what to find and what to replace. How do I do this in PHPStorm?

like image 717
Lloyd Banks Avatar asked Mar 24 '13 18:03

Lloyd Banks


People also ask

How do I search for a word in PhpStorm?

From the main menu, select Edit | Find | Find in Files Ctrl+Shift+F . In the search field, type your search string. Alternatively, in the editor, highlight the string you want to find and press Ctrl+Shift+F . PhpStorm places the highlighted string into the search field.

How do I replace a word in a regular expression?

To use RegEx, the first argument of replace will be replaced with regex syntax, for example /regex/ . This syntax serves as a pattern where any parts of the string that match it will be replaced with the new substring. The string 3foobar4 matches the regex /\d. *\d/ , so it is replaced.


1 Answers

If you are using the Default keymapping (you can also use the keymaps for Eclipse, Visual Studio, etc) press Ctrl+r to show the Replace Toolbar. If you already have a selection then the option In Selection will already be checked, otherwise you can check it and then do your selection (if you select first and check the option second it will unselect the text after checking the option).

The feature is called Replace in the Keymap configuration if you wish to change the shortcut.

You can also press Shift+F6 to directly rename variables if that's what you want to do.

like image 89
solarc Avatar answered Oct 24 '22 00:10

solarc