Sublime中开发React Native的插件
用Sublime搞了好久的RN,发现对RN的语法真的鸡肋,特此在网上搜集了一些相关的插件。
安装插件前期准备
注:先检查是否已经安装好了Package Control,如果已经安装好了就无需重复安装如果在菜单Preferences下面有Package Control则表示已经安装过了
View->Show Console菜单打开命令行,粘贴如下代码:
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)
安装后好,打开Package Control(Preferences -> Package Control)输入install,然后再输入想要安装的插件名称就可以安装插件了
1. ReactJS支持React.js代码提示,高亮显示等...官网:https://github.com/facebookarchive/sublime-react效果图:
**2. Emmet **使用仿CSS选择器的语法来生成代码,大大提高了HTML/CSS代码编写的速度官网:https://github.com/sergeche/emmet-sublime效果图:
配置:
a). 修改 Emmet 兼容jsx 文件菜单 preferences -> Key bindings - Users,把下面代码复制到[ ]内部
{ "keys": [ "super+e" ], "args": { "action": "expand_abbreviation" }, "command": "run_emmet_action", "context": [{ "key": "emmet_action_enabled.expand_abbreviation" }] }, { "keys": ["tab"], "command": "expand_abbreviation_by_tab", "context": [{ "operand": "source.js", "operator": "equal", "match_all": true, "key": "selector" }, { "key": "preceding_text", "operator": "regex_contains", "operand": "(\b(a\b|div|span|p\b|button)(\.\w|>\w)?([^}]*?}$)?)", "match_all": true }, { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }] }
使用super+e 触发 emmet;正则判断用 a,div,span,p,button标签默认tab 触发;默认 class 修改为 className注:supre+e 在 PC 上指的是win+e (pc 建议修改为emmet 默认按键 ctrl+e),在 mac 上指的是cmd+e
3. babel-sublime支持ES6, React.js, jsx代码高亮官网:https://github.com/babel/babel-sublime配置:打开.js, .jsx 后缀的文件后,点击菜单View -> Syntax -> Open all with current extension as... -> Babel -> JavaScript (Babel),即可设置babel为默认 javascript 打开syntax
4. react-native-snippets提供了一些react-native的代码快速构建模板官网:https://github.com/Shrugs/react-native-snippets
5. JsFormatjs格式化官网:https://github.com/jdc0589/JsFormat
配置:a). 让其支持JSX菜单 preferences -> Package Settings -> JsFormat -> Setting - Users,输入以下代码:
{ "e4x": true, // jsformat options "format_on_save": true,}
6. Terminal快速打开终端并定位到当前项目所在目录官网:https://github.com/wbond/sublime_terminal