【工具】sublime text3个人习惯配置

1、安装

分别在官网下载并安装 nodejssublime text3

2、sublime text3注册:

点击菜单【help】->【Enter License】,粘贴注册码。

3、安装package control组件,用于管理所有插件

按ctrl + ~调出控制台(或点击菜单栏的【View】->【Show Console】),在Console窗口中输入以下代码,按回车键:

1
import urllib.request,os,hashlib; h = '2915d1851351e5ee549c20394736b442' + '8bc59f460fa1548d1514676163dafc88'; pf = 'Package Control.sublime-package'; ipp = sublime.installed_packages_path(); urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler()) ); by = urllib.request.urlopen( 'http://packagecontrol.io/' + pf.replace(' ', '%20')).read(); dh = hashlib.sha256(by).hexdigest(); print('Error validating download (got %s instead of %s), please try manual install' % (dh, h)) if dh != h else open(os.path.join( ipp, pf), 'wb' ).write(by)

等待安装完毕,重启Sublime Text3。
按快捷键:Ctrl+Shift+P,调出界面,在其中输入:install,第一个选项即是Package Control:

4、用Package Control安装插件

按快捷键:Ctrl+Shift+P,调出界面,按照个人习惯安装插件(以下是我使用的插件)
Material Theme
Emmet
CSS Format
CSScomb
jsFormat
AutoFileName
Autoprefixer
Doc Blockr
SublimeLinter
SublimeLinter-jshint
SublimeLinter-csslint
Color Highlighter
BracketHighlighter

5、配置nodejs

方法1

(1)下载sublime Text的nodejs插件
(2)下载后解压:直接改名为nodejs 放到 Preferences–>浏览程序包Browse Packages所在的文件夹
(3)修改配置:打开Nodejs文件夹,找到文件“Nodejs.sublime-build”, 拖拽到sublime,显示:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "cp1252",
"windows":
{
"cmd": ["taskkill /F /IM node.exe & node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
},
"osx":
{
"cmd": ["killall node; node $file"]
}
}

(4)修改为:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "utf-8",
"windows":
{
"cmd": ["taskkill /F /IM node.exe", ""],
"cmd": ["node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
},
"osx":
{
"cmd": ["killall node; node $file"]
}
}

(5)完成:随便写一段nodejs代码,ctrl+B运行
(6)注意:在手动解压sublime Text插件后,需要在preference->package settings->package control的user setting下添加installed packages中的“Nodejs”,不然重启sublime Text 会被删除Nodejs插件。

方法2

首先需要先安装nodejs
(1)运行Sublime,菜单上找到Tools —> Build System —> new Build System
(2)输入:
{
“cmd”: [“node”, “$file”],
“file_regex”: “^[ ]File "(…?)", line ([0-9]*)”,
“selector”: “source.js”,
“shell”:true,
“encoding”: “utf-8”,
“windows”:
{
“cmd”: [“taskkill /F /IM node.exe”, “”],
“cmd”: [“node”, “$file”]
}
}
(3)保存文件为NodeJs.sublime-build
(4)菜单上找到Tools —> Build System —>选择 NodeJs
(5)安装sublime插件 JavaScript & NodeJs Snippets
(6)新建test.js文件,输入 console.log(‘Hello Node.js’); 按快捷键 Ctrl + B 运行,成功输出