美文网首页
06创建自己的snippet

06创建自己的snippet

作者: masakakaikai | 来源:发表于2015-06-21 05:02 被阅读40次

在:
C:\Users\kai\AppData\Roaming\Sublime Text 3\Packages\User
新建一个文件

可以存成这个文件名:
cc.sublime-snippet

里面这么写:


<snippet>
    <content><![CDATA[
//USER NAME:          Renkai Wang
//FILE NAME:          $TM_FILENAME

#include <stdio.h>
#include <stdlib.h>
#include <string.h>    
#include <time.h>

int main(int argc, char const *argv[])
{
    ${1:/* code */}
    
    return 0;
}




]]></content>
<tabTrigger>cc</tabTrigger>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <!-- <tabTrigger>hello</tabTrigger> -->
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>


这样每次呼唤cc,就可以引出这样的代码段了。
大胜利!!


python的snippet


<snippet>
    <content><![CDATA[
# -*- coding:utf-8 -*-  
# USER NAME:          Renkai Wang
# FILE NAME:          hello.py
import os
import re
import sys
import os.path
import random

${1:coding...}
]]></content>
<tabTrigger>py</tabTrigger>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <!-- <tabTrigger>hello</tabTrigger> -->
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>



cpp数据结构的


<snippet>
    <content><![CDATA[
//USER NAME:          Renkai Wang
//FILE NAME:          $TM_FILENAME
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <string>
#include <string.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <cstdio>
#include <ctime>
#include <cmath>

using namespace std;

int main(int argc, char const *argv[])
{
    ${1:/* code */}
    return 0;
}



]]></content>
<tabTrigger>cpp</tabTrigger>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <!-- <tabTrigger>hello</tabTrigger> -->
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- <scope>source.python</scope> -->
</snippet>



相关文章

网友评论

      本文标题:06创建自己的snippet

      本文链接:https://www.haomeiwen.com/subject/ldisqttx.html