今天在用canvas绘图时,看到有许多相同的代码,就想介绍sublime里面为了加快代码编写,而采用代码片段。
这里只写我了解的。其他需要,请读者自行了解。
打开位置,见下图:
打开页面
例子
<snippet> <content> <![CDATA[ <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>${1}</title> </head> <body> <canvas id="demo"> </canvas> <script> (function() { var canvas = document.getElementById('demo'); canvas.width = ${2:agewg}; canvas.height = ${3}; canvas.style.border = '1px solid #000'; var ctx = canvas.getContext('2d'); ${4} ctx.stroke(); })(); \$(function() { }); </script> </body> </html> ]]> </content> <!-- Optional: Set a tabTrigger to define how to trigger the snippet --> <tabTrigger>cans</tabTrigger> <!-- Optional: Set a scope to limit where the snippet will trigger --> <!-- <scope>source.python</scope> --></snippet>下面图片和上面代码块一样的内容,为了说明清楚,加的图片:
保存
输入快捷键
以上就是如何用sublime编写代码块的详细内容,更多请关注php中文网其它相关文章!
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号