简体   繁体   English

PHPStorm - 在选择中查找和替换文本?

[英]PHPStorm - Find and Replace Text in Selection?

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. 在大多数其他编辑器中,我可以选择要运行的文本的一部分查找并替换,然后点击ctrl + h组合。 A screen pops up asking me what to find and what to replace. 弹出一个屏幕询问我要找什么以及要替换什么。 How do I do this in PHPStorm? 我如何在PHPStorm中执行此操作?

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. 如果您使用默认键映射(您也可以使用Eclipse,Visual Studio等的键盘映射),请按Ctrl+r以显示替换工具栏。 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). 如果您已经有一个选择,那么已经选中了In Selection选项,否则您可以检查它然后进行选择(如果您先选择并选中第二个选项,它将在选中该选项后取消选择该文本)。

The feature is called Replace in the Keymap configuration if you wish to change the shortcut. 如果要更改快捷方式,则在Keymap配置中将此功能称为“ Replace

You can also press Shift+F6 to directly rename variables if that's what you want to do. 您也可以按Shift+F6直接重命名变量,如果这是你想要做的。

  1. Highlight the code selection you wish to work on ( you can use alt + arrow up if your looking for a cool way to do that) 突出显示您希望处理的代码选择(如果您正在寻找一种很酷的方法,可以使用alt + arrow up
  2. Press Ctlr + r on PC or Command + r on a Mac 在PC上按Ctlr + r或在Mac上按Command + r
  3. In the upper options window, insert the values you wish to replace 在上方选项窗口中,插入要替换的值
  4. Select the "in selection" check box 选中“在选择中”复选框
  5. Press Replace/Replace all button 按Replace / Replace all按钮

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM