美文网首页
(0)一些提升学习效率的Tip

(0)一些提升学习效率的Tip

作者: plusman | 来源:发表于2015-05-20 00:46 被阅读75次

更好的代码阅读体验,请移步 作业部落 (0)一些提升学习效率的Tip


Q sublime mac build 3059 添加node.js的build system设置方法
打开 Tools -> Build System -> New Build System
新建 node.sublime-build 编译系统配置文件,内容如下

{   
  "cmd": ["/usr/local/bin/node", "$file"],   
  "selector": "source.js"   
}

保存为,node.sublime-build
以后,写完node.js测试代码后,可以直接 Command + B 运行代码

Ps:有时候不知道写完的配置文件该往哪里放,可以先随便新建一个配置,保存后在文件正文内点击右键,选择 “Reveal In Finder”(Mac),其他系统应该是在“文件内打开“,找到目录后,删除刚才新建的文件。


Q sublime snippets 快速输入代码片段
对于一些常用的代码片段,可以做成snippet的形式,避免重复输入。

菜单栏 Tools -> New Snippet ,会看到

<snippet>
    <!-- 注意Hello 是顶格书写的,不然会造成插入时候的缩进问题 -->
    <content><![CDATA[
Hello, ${1:this} is a ${2:snippet}. Yes, i am a beautiful ${1:this}
]]></content>
    <!-- Optional: Set a tabTrigger to define how to trigger the snippet -->
    <!-- 可选:代码snippet触发关键字 -->
    <tabTrigger>hello</tabTrigger>
    <!-- Optional: Set a scope to limit where the snippet will trigger -->
    <!-- 可选:选择这个代码片段试用的脚本类型,此处为选择所有 *.js文件 -->
    <scope>source.js</scope>
    <!-- 可选:代码片段描述 -->
    <description>hello sinppet</description>
</snippet>

ctrl+s 保存为 hello.sublime-snippet,文件名没有要求,建议和 tabTrigger 一致,方便后期管理。在 '*.js'类型的文件内输入,关键字 'hello',会看到下图。

snippet提示

按下Tab键后,屏幕上会出现下文,此时两个this是被选中的,可以直接批量编辑,再次按下Tab键,snippet被选中。对照 hello.sublime-snippet 内 content 的定义,能发现规则。

Hello, this is a snippet. Yes, i am a beautiful this

相关文章

网友评论

      本文标题:(0)一些提升学习效率的Tip

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