Sublime Text wrap selection with snippet

别等时光非礼了梦想. 提交于 2019-12-02 15:29:49
Sergey Telshevsky

As can be seen here:

Tools -> New Snippet... -> save as darken.sublime-snippet in Data\Packages\User\

<snippet>
    <content><![CDATA[darken($SELECTION, 5%);]]></content>
    <!-- Optional: Tab trigger to activate the snippet -->
    <tabTrigger>darken</tabTrigger>
    <!-- Optional: Scope the tab trigger will be active in -->
    <scope>source.css</scope>
    <!-- Optional: Description to show in the menu -->
    <description>Darken Snippet</description>
</snippet>

And keybind:

{ "keys": ["ctrl+shift+o"], 
  "command": "insert_snippet", 
  "args": { "name": "Packages/User/darken.sublime-snippet" } },

EDIT: It would be even better if you add $1 right after the $SELECTION, then the cursor will jump to the selected word or right in the place where it has to be written if it's not selected.

Change the above snippet's second line to this:

<content><![CDATA[darken($SELECTION$1, 5%);]]></content>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!