sublime使用常见技巧举例2

著作权归作者所有。
商业转载请联系作者获得授权,非商业转载请注明出处。
作者:Jasin Yip
链接:http://www.zhihu.com/question/24896283/answer/29380046
来源:知乎

使用 Sublime Text 建议掌握常用命令
1、查找打开过的文件:Ctrl+P,然后输入最近的文件名就可以即时预览到文件内容。
<img src="https://i-blog.csdnimg.cn/blog_migrate/3eb99412f943154a8adf25cb65b7763e.png" data-rawwidth="1027" data-rawheight="577" class="origin_image zh-lightbox-thumb" width="1027" data-original="https://pic3.zhimg.com/9b7c4d67ea55e27ec8948fb2c62b52ce_r.jpg">2、命令输入框(不知道是不是这样叫):Ctrl+Shift+P 2、命令输入框(不知道是不是这样叫):Ctrl+Shift+P
a)切换语法模式:
Set Syntax : [编程语言]
可以缩写为:
sspy
<img src="https://i-blog.csdnimg.cn/blog_migrate/455c8161102bc21672030cf594820336.png" data-rawwidth="568" data-rawheight="165" class="origin_image zh-lightbox-thumb" width="568" data-original="https://pic4.zhimg.com/cd557aaf5aa2070371c02f3c36d1b6d7_r.jpg">这样就可以切换语法模式了,这以便于代码高亮及插件调用(比如HTML模式会使Emmet生效) 这样就可以切换语法模式了,这以便于代码高亮及插件调用(比如HTML模式会使Emmet生效)
b)安装插件(前题是你安装了插件管理器):
<img src="https://i-blog.csdnimg.cn/blog_migrate/e65369b9793356485ef99fa6a8a3ef19.png" data-rawwidth="569" data-rawheight="76" class="origin_image zh-lightbox-thumb" width="569" data-original="https://pic2.zhimg.com/22ea96a4a0a384ea7489ad158af5cb4d_r.jpg">
输入这个命令之后回车,再输入需要的插件,就可以安装了。
<img src="https://i-blog.csdnimg.cn/blog_migrate/d4ba7b8377f2faeaa241df7073453e4c.png" data-rawwidth="425" data-rawheight="421" class="origin_image zh-lightbox-thumb" width="425" data-original="https://pic1.zhimg.com/4d0c279219fa579b46cccca30604ae60_r.jpg">
3、多处编辑功能:
Ps:这个功能至关重要,我都不敢回想接触 Sublime Text 以前是怎么活过来的。
比如这样的代码:
<div>
  <h2></h2>
  <p></p>
  <p></p>
</div>
<div>
  <h2></h2>
  <p></p>
  <p></p>
</div>
<div>
  <h2></h2>
  <p></p>
  <p></p>
</div>
如果我需要为所有 h2 换成 h1,再加上一个 class="title" 属性:
那么我只需要选中一个 h2,然后按住 Ctrl+D (因为按一下只会只选择下一个)
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/a199ac06a61c0e263d5b1cda68b205d6.png&quot; data-rawwidth=&quot;265&quot; data-rawheight=&quot;452&quot; class=&quot;content_image&quot; width=&quot;265&quot;&amp;gt;于是就变成: 于是就变成:
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/fdadfff0caac820953732bc13ebb985f.png&quot; data-rawwidth=&quot;286&quot; data-rawheight=&quot;428&quot; class=&quot;content_image&quot; width=&quot;286&quot;&amp;gt;然后我就可以输入 h1 ,就变成 然后我就可以输入 h1 ,就变成
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/1a8f9dc26e12712ca80ef6cc61c8c832.png&quot; data-rawwidth=&quot;209&quot; data-rawheight=&quot;428&quot; class=&quot;content_image&quot; width=&quot;209&quot;&amp;gt;
这个时候,按一下 HOME (Mac下是Commond + 左箭头),再按几下右箭头,再输入
 class="title"
然后就变成
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/41a9d9258fca1cdae9f51cf7f9a96013.png&quot; data-rawwidth=&quot;389&quot; data-rawheight=&quot;423&quot; class=&quot;content_image&quot; width=&quot;389&quot;&amp;gt;
欧了~!
这个可以举一反三,巨有用巨实用!




当然 Ctrl + F 调出查找功能、Ctrl + Shift + F 调出查找并替换功能应该不用讲了。


关于编码
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/07af8d33f0bbfccd14293b7318608e41.png&quot; data-rawwidth=&quot;570&quot; data-rawheight=&quot;426&quot; class=&quot;origin_image zh-lightbox-thumb&quot; width=&quot;570&quot; data-original=&quot;https://pic3.zhimg.com/4441773188b44583f7bf8ea235a4dd4e_r.jpg&quot;&amp;gt;
File -> Reopen with Encoding 可以以某编码打开
File -> Save with Encoding 可以保存为某一编码
编码问题就是这么简单~


关于中键,也就是 鼠标滚轮
鼠标滚轮也可以选中字符,但不同用鼠标左键选择的是,他不会跨行选择,而是直接 矩形选择,比如:
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/2a5c22d70388f17103ffa30c2fe7b826.png&quot; data-rawwidth=&quot;161&quot; data-rawheight=&quot;202&quot; class=&quot;content_image&quot; width=&quot;161&quot;&amp;gt;配合 Ctrl 多处选择进行多处编辑,这直接是赞爆了有木有!! 配合 Ctrl 多处选择进行多处编辑,这直接是赞爆了有木有!!



还有菜单里这个功能超赞!可以快速设置 Tab 的宽度,默认是4,也可以 Spaces 与 Tabs 之间转换。
(btw, 习惯用 Tab 缩进的程序猿,在提交代码时转换成2个空格的缩进是个好习惯)
&amp;lt;img src=&quot;https://i-blog.csdnimg.cn/blog_migrate/9a3654f23da32b01c894d37c6e4f60f8.png&quot; data-rawwidth=&quot;599&quot; data-rawheight=&quot;610&quot; class=&quot;origin_image zh-lightbox-thumb&quot; width=&quot;599&quot; data-original=&quot;https://pic2.zhimg.com/8c775c3efb3a2aef22d2cff88b993669_r.jpg&quot;&amp;gt;


关于插件
插件太多了,Google/百度/知乎一搜就有推荐的,这里写推荐一个~!
写前端的话 Emmet 插件是必须的,比如:
输入
html:5
按TAB,会这样
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>Document</title>
</head>
<body>
	
</body>
</html>

输入
div
按TAB,会这样
<div></div>

输入
section#block$*3>h2.title+p.words*2
按TAB,会这样
<section id="block1">
  <h2 class="title"></h2>
  <p class="words"></p>
  <p class="words"></p>
</section>
<section id="block2">
  <h2 class="title"></h2>
  <p class="words"></p>
  <p class="words"></p>
</section>
<section id="block3">
  <h2 class="title"></h2>
  <p class="words"></p>
  <p class="words"></p>
</section>

还有很多用法,可以自行Google/百度 “Emmet”。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值