通常在编码和模板中,我需要包装文本的某一部分。是否有包装当前选定内容的快捷方式,例如:
Hello World "Hello World" Hello World {{ trans 'Hello World' }}
进出口使用 PhpStorm 7的 Mac 和 PC。我发现了一些类似的东西,使用: ctrl + alt + j,你可以用 html-tag 包装,但是没有其他东西。还有 ctrl + alt + -根据当前文件格式(php,twig,html,...)注释当前选择
我知道这是一个有点晚的答案,但我希望任何人谁看到这个问题得到帮助。 在 PhpStorm 中,几乎所有的东西都可以配置,但是有点复杂,需要一些学习曲线。
选择一个单词并输入单引号(或双引号)来包围它是非常常见的行为。
Hello World 'Hello World' "Hello World"
要实现这一点,请在 Preferences -> IDE -> Editor -> Smart Keys -> Surround Selection on typing quote or brace的复选框上打勾。
Preferences -> IDE -> Editor -> Smart Keys -> Surround Selection on typing quote or brace
另一种方法是选择某些内容(单词、条件) ,然后按 Cmd + Alt + T(在 Mac 上) ,Ctrl + Alt + T(在 Windows 上)。将显示可用的 Surround With选项对话框。
Surround With
对于 PhpStorm 版本8,在 Preferences -> Editor -> General -> Smart Keys -> Surround selection on typing quote or brace的复选框上打勾。
Preferences -> Editor -> General -> Smart Keys -> Surround selection on typing quote or brace
For 2016年 PhpStorm 版本, use Cmd + Alt + S (on Mac) or Ctrl + Alt + S (on Win) to go to 设定. Tick on checkbox of 设置-> 编辑器-> 常规-> 智能键-> 在键入“引号”或“括号”时环绕选项.
As of 2015-02-26 (PhpStorm 8) go to:
File > Settings... > Editor > General > Smart Keys > Surround selection on typing quote or brace
在 Mac 上
PhpStorm > Preferences > Editor > General > Smart Keys > Surround selection on typing quote or brace.
PhpStorm > Preferences > Editor > General > Smart Keys > Surround selection on typing quote or brace
还可以按 command+,打开“首选项”菜单。
command+,
如何创建一个活动模板,以便轻松地将 Hello World变成 \{\{ trans 'Hello World' }}:
Hello World
\{\{ trans 'Hello World' }}
\{\{ trans '$SELECTION$' }}
然后从上面选择 Hello World并使用 步骤1,选择一个带有“缩写”的规则
这只是一个比@Steve. NayLinAung 更详细的回答。 感谢@LazyOne