sublime: javascript/css 的格式化

Sublime Text 3 破解版 + 注册机 + 汉化包 + 教程

http://www.xiumu.org/note/sublime-text-3.shtml

1、sublime 如果控制菜单选项不见了

  alt - view- show console

2、如何将js 格式化

  • 在Sublime Text中,按下Ctrl+Shift+P调出命令面板;
  • 输入install 调出 Install Package 选项并回车;
  • 输入pretty,并在列表中选择HTML-CSS-JS Prettify后回车即可安

举例:
打开一个压缩的jquery.min.js文件,按下Ctrl+Shift+H

如果快捷键和其他软件有重合。比如ctrl+shif+H 好像是搜狗输入法的换皮肤快捷键。

preference -package setting-html-css-js prettyf - prettify

 但是这个需要安装nodejs 。

不知道为何,我尝试安装nodejs 结果下载下来的msi 和exe 文件都无法安装。这个还挺麻烦的。

考虑用jsformat 这个插件:

卸载插件的方法:

1.ctr+shift+P,输入package
2.查找remove package
3.输入你要删除的package
4.回车,OK


安装jsformat 的方法:
ctrl+shif+p 输入install package
找到jsformat
点击安装。

但是出现了以下错误,百度没有找到结果!!!

 

没办法。。。只能从安装插件控制器开始重新一步步走。

首先看package contrler 有没有安装好。不希望用在sublime text console 中复制代码的方式安装。选择了手动安装。如下步骤

Manual

If for some reason the console installation instructions do not work for you (such as having a proxy on your network), perform the following steps to manually install Package Control:

  1. Click the Preferences > Browse Packages… menu
  2. Browse up a folder and then into the Installed Packages/ folder
  3. Download Package Control.sublime-package and copy it into theInstalled Packages/ directory
  4. Restart Sublime Text
然后在使用jsformat 安装。

安装jsformat 的方法:
ctrl+shif+p 输入install package
找到jsformat
点击安装。

ctrl+alt+format
结果ok!!


注意,虽然是jsformat, 但是对css 也有很好的支持效果。。

如果觉得sublime真的很麻烦.....

可以通过在线格式化
给一个网站地址:
http://www.5lulu.com/tec/Online_js.html




3、css format 的package.

CompactExpandCss

select the css code

*{
    padding:0
}

and press ctrl + alt(command) + [ , the code becomes

*{ padding:0}

select the css code and press ctrl + alt(command) + ] , the code becomes

*{
    padding:0
}
原文地址:https://www.cnblogs.com/flymood/p/4263676.html