zoukankan      html  css  js  c++  java
  • Sublime Text3高效开发之编写代码块(snippet)

    看到别人使用HBuilder X可以插入代码块,就想sublime text3有没有类似的功能呢,诶还真有。在sublime text3叫作snippet。

    -snippet是干什么的?:可以在你编写js,html,vue,python...的时候快速插入自定义的代码块。

    演示demo

    输入bt4carousel

    输入完bt4carousel按Tab

     代码生成完毕!

    -snippet怎么使用?:新建sublime-snippet文件,编写代码块,保存文件即可使用。

    如何新建sublime-sinppet文件?

    新建如下

    Vue实例

    <snippet>
        <content><![CDATA[
    <div id="carouselExampleIndicators" class="carousel slide" data-ride="carousel">
      <ol class="carousel-indicators">
        <li data-target="#carouselExampleIndicators" data-slide-to="0" class="active"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="1"></li>
        <li data-target="#carouselExampleIndicators" data-slide-to="2"></li>
      </ol>
      <div class="carousel-inner">
        <div class="carousel-item active">
          <img class="d-block w-100" src="${1:this}" alt="${2:this}">
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="${3:this}" alt="${4:this}">
        </div>
        <div class="carousel-item">
          <img class="d-block w-100" src="${5:this}" alt="${6:this}">
        </div>
      </div>
      <a class="carousel-control-prev" href="#carouselExampleIndicators" role="button" data-slide="prev">
        <span class="carousel-control-prev-icon" aria-hidden="true"></span>
        <span class="sr-only">Previous</span>
      </a>
      <a class="carousel-control-next" href="#carouselExampleIndicators" role="button" data-slide="next">
        <span class="carousel-control-next-icon" aria-hidden="true"></span>
        <span class="sr-only">Next</span>
      </a>
    </div>
    ]]></content>
        <!-- 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> -->
        <tabTrigger>bt4carousel</tabTrigger>
        <!-- <scope>text.html.basic</scope> -->
        <scope>text.html.vue</scope>
    </snippet>
    View Code

    Ctrl+S保存 推荐.......Sublime Text 3PackagesUser下新建snippets文件夹

    恭喜,自定义的snippet可以使用了,赶紧自己去试试吧。

    如何查看特定文件的<scope>的值?:ctrl+alt+shift+p或者菜单栏-tools-developer-Show Scope Name,就能看到对应的值啦,点击copy就可以复制值。

    以上就sublime text3之snippet基本使用的所有内容,祝使用愉快,再见。

  • 相关阅读:
    scp命令
    遇到的错误解决方法
    阿里云挂载数据盘
    正则表达式
    python例子三
    Linux shell快捷键
    《超级产品的本质:汽车大王亨利福特自传》书评
    学习嵌入式的一点建议【转】
    win7使用USB转串口连接mini2440方法
    吐血原创:mini2440和win7笔记本利用无路由功能的交换机共享上网(使用x-router软路由)
  • 原文地址:https://www.cnblogs.com/runrunrun/p/11615735.html
Copyright © 2011-2022 走看看