问题
I want to simplify the typing of this:
export const RECEIVE_POSTS = 'RECEIVE_POSTS'
I then came up with this snippet:
<snippet>
<content><![CDATA[
export const ${1/(.+)/\U$1/g} = '${1/(.+)/\U$1/g}'
${1}
]]></content>
<tabTrigger>con</tabTrigger>
<scope>source.js</scope>
<description>ES6 Module Export Variable</description>
</snippet>
However, the downside is that I need to delete the originally typed input.
Is is possible that the letters be automatically transformed into all-caps when first typing in the field${1}?
回答1:
I don't have a perfect solution, but this is an improved snippet:
<snippet>
<content><![CDATA[
export const ${1/(.+)/\U$1/g} = '$1'
]]></content>
<tabTrigger>con</tabTrigger>
<scope>source.js</scope>
<description>ES6 Module Export Variable</description>
</snippet>
This will convert the part before the =
to uppercase. The part after that will be lowercase, but Sublime Text immediately offers to complete it to the uppercase variant. Tested in Sublime Text 3.
来源:https://stackoverflow.com/questions/38681945/sublime-text-2-snippet-all-caps-when-typing-in-fields