0

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}?

The questioner
  • 724
  • 10
  • 21

1 Answers1

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.

idleberg
  • 12,634
  • 7
  • 43
  • 70