VS Code - 带有测试方法空格的代码片段转换文本
VS Code - Snippet Transform text with spaces for test methods
我已经在 Sublime Text 3 中使用了这个有用的片段一段时间,我正尝试在 VS Code 中复制它但没有成功。
<snippet>
<content><![CDATA[
/** @test */
public function ${1/\s/_/g}()
{
${0:// ${1:type name of method with spaces}}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>phpunit</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.php</scope> -->
</snippet>
我基本上在 VS Code 中创建了相同的片段,但它抱怨 \s
是无效的转义字符。
我哪里错了?是否缺少对查找 space 个字符的支持?
希望此代码段再次运行,因为它可以节省时间。
只需双重转义即可:
public function ${1/\s/_/g}()
它会很好地工作。见 transform examples and escaping:
The examples are shown within double quotes, as they would appear inside a snippet body, to illustrate the need to double escape certain characters.
我已经在 Sublime Text 3 中使用了这个有用的片段一段时间,我正尝试在 VS Code 中复制它但没有成功。
<snippet>
<content><![CDATA[
/** @test */
public function ${1/\s/_/g}()
{
${0:// ${1:type name of method with spaces}}
}
]]></content>
<!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
<tabTrigger>phpunit</tabTrigger>
<!-- Optional: Set a scope to limit where the snippet will trigger -->
<!-- <scope>source.php</scope> -->
</snippet>
我基本上在 VS Code 中创建了相同的片段,但它抱怨 \s
是无效的转义字符。
我哪里错了?是否缺少对查找 space 个字符的支持?
希望此代码段再次运行,因为它可以节省时间。
只需双重转义即可:
public function ${1/\s/_/g}()
它会很好地工作。见 transform examples and escaping:
The examples are shown within double quotes, as they would appear inside a snippet body, to illustrate the need to double escape certain characters.