Sublime Text 2 snippet all-caps when typing in fields

北城余情 提交于 2019-12-12 03:16:01

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!