[![Join the chat at https://gitter.im/jdc0589/JsFormat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jdc0589/JsFormat?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
## About
JsFormat is a javascript formatting plugin for Sublime Text 2.
It uses [jsbeautifier](https://github.com/beautify-web/js-beautify) to format whole js or json files, or the selected portion(s).
## Features
* javascript/json formatting (obviously)
* all settings are customizable (whitespace, formatting style, etc..)
* .jsbeautifyrc settings files support for even more control on a per-project basis
* puts the cursor back in the same location it was before formatting (accounts for whitespace/newline changes)
* Sublime Text 3 support
## Settings
JsFormat uses whatever tab/indent settings are configured with the standard ```translate_tabs_to_spaces``` and ```tab_size``` sublime settings.
The following **JsBeautifier** settings are available in JsFormat/JsFormat.sublime-settings (defaults shown below). Check out the official [jsbeautifier documentation](https://github.com/einars/js-beautify#options) for more details on the options:
* `indent_with_tabs`: false
* `max_preserve_newlines`: 4
* `preserve_newlines`: true
* `space_in_paren`: false
* `jslint_happy`: false
* `brace_style`: "collapse"
* `keep_array_indentation`: false
* `keep_function_indentation`: false
* `eval_code`: false,
* `unescape_strings`: false,
* `break_chained_methods`: false*
* `e4x`: false
* `wrap_line_length`: 0
* `space_after_anon_function`: false
The following **JsFormat** specific settings are also exposed:
- `format_on_save`: false (format files on buffer save)
- `jsbeautifyrc_files`: false (see the [.jsbeautifyrc files](#jsbeautifyrc-files) section)
I had temporary lapse of judgment a while back and merged a pull request that modified jsbeautifier. As a result, the functionality that
was added from that pull request has been lost; ```"ensure_space_before_linestarters"``` is no longer supported.
The JsFormat specific ```ensure_newline_at_eof_on_save``` setting has also been removed. This functionality exists in sublime core.
#### jsbeautifyrc files ####
JsFormat now supports `.jsbeautifyrc` JSON files (disabled by default), which themselves support any of the exposed JsBeautifier options. The option augmentation order is: default options -> user settings -> `.jsbeautifyrc` option files.
A hierarchy of `.jsbeautifyrc` files is supported, where rc files at the deeper levels override the settings from rc files at higher levels. For example, given the file structure listed below, formatting `/home/you/myProject/app.js` would inherit settings from: default -> user settings -> `/home/you/myProject/.jsbeautifyrc`, while formatting `/home/you/myProject/tests/test.js` would inherit settings from: default -> user settings -> `/home/you/myProject/.jsbeautifyrc` -> `/home/you/myProject/tests/.jsbeautifyrc`
- /home/you/myProject/.jsbeautifyrc
- /home/you/myProject/app.js
- /home/you/myProject/tests/.jsbeautifyrc
- /home/you/myProject/tests/test.js
## Install
#### [Package Control](https://github.com/wbond/sublime_package_control) (Recommended)
JsFormat is now included in the default repository channel for [Package Control](https://github.com/wbond/sublime_package_control). It should show up in your install list
with no changes.
If it does not show up, or you are on an older version of Package Control,
add https://github.com/jdc0589/JsFormat as a Package Control repository. JsFormat will show up in the
package install list.
#### Git Clone
Clone this repository in to the Sublime Text 2 "Packages" directory, which is located where ever the
"Preferences" -> "Browse Packages" option in sublime takes you.
## Key Binding
The default key binding is "ctrl+alt+f"
## Key Binding Conflicts
Unfortunately there are other plugins that use "ctrl + alt + f", this is a hard problem to solve. If JsFormat works
OK via the command palette but does nothing when you use the "ctrl + alt + f" shortcut, you have two options:
1. Add ```{ "keys": ["ctrl+alt+f"], "command": "js_format", "context": [{"key": "selector", "operator": "equal", "operand": "source.javascript"}] }``` to your user keybindings file. This will override anything specified by a plugin.
2. Find the offending plugin, and change the shortcut in its sublime-keymap file (will revert on updates)
## Command Palette
Open the command palette via "ctrl + shift + p", Jsformat appears as "Format: Javascript"
---
### License
Copyright (C) 2012 Davis Clark
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
没有合适的资源?快使用搜索试试~ 我知道了~
Sublime Text2的JsFormat插件
共66个文件
py:36个
js:4个
sublime-keymap:3个
5星 · 超过95%的资源 需积分: 9 60 下载量 132 浏览量
2015-10-14
17:38:24
上传
评论
收藏 144KB ZIP 举报
温馨提示
Sublime Text2 的Js插件,点击Sublime下的Preferen ——> Browse Packages,将压缩包解压后的文件复制到打开的文件夹下,重启Sublime即可。
资源推荐
资源详情
资源评论
收起资源包目录
JsFormat-master.zip (66个子文件)
JsFormat-master
Main.sublime-menu 4KB
Context.sublime-menu 99B
JsFormat.sublime-settings 530B
JsFormat.sublime-commands 67B
Default (Windows).sublime-keymap 169B
Default (Linux).sublime-keymap 151B
src
jsf_activation.py 426B
jsf_rc.py 1KB
jsf.py 3KB
js_formatter.py 3KB
.gitignore 6B
README.md 5KB
Default (OSX).sublime-keymap 169B
libs
six-1.8.0
MANIFEST.in 114B
documentation
conf.py 7KB
Makefile 4KB
index.rst 33KB
tox.ini 234B
LICENSE 1KB
CHANGES 6KB
README 769B
setup.cfg 22B
test_six.py 20KB
setup.py 852B
six.py 27KB
CONTRIBUTORS 485B
jsbeautifier
MANIFEST.in 45B
js-beautify-profile 232B
js-beautify-test 153B
jsbeautifier
tests
shell-smoke-test.sh 5KB
testjsbeautifier.py 106KB
test-perf-jsbeautifier.py 1KB
testindentation.py 1KB
__init__.py 16B
__init__.py 78KB
unpackers
javascriptobfuscator.py 2KB
packer.py 4KB
README.specs.mkd 1017B
tests
testurlencode.py 994B
test-myobfuscate-output.js 2KB
test-packer-62-input.js 4KB
test-myobfuscate-input.js 7KB
testjavascriptobfuscator.py 2KB
__init__.py 40B
testpacker.py 1KB
test-packer-non62-input.js 4KB
testmyobfuscate.py 1KB
evalbased.py 1KB
__init__.py 2KB
myobfuscate.py 3KB
urlencode.py 982B
__version__.py 22B
setup.py 724B
js-beautify 118B
cssbeautifier
tests
test.py 16KB
__init__.py 16B
__init__.py 14KB
__version__.py 22B
merge_utils.py 3KB
diff_match_patch
README.txt 1KB
python2
diff_match_patch.py 66KB
__init__.py 59B
__init__.py 102B
python3
diff_match_patch.py 66KB
__init__.py 59B
COPYING 10KB
共 66 条
- 1
资源评论
- 时间去了哪丶2016-06-14挺好用的,要是有java格式化的就好了
- sqxu2016-07-29还不错,感谢分享
- PG1632019-05-05还不错,!!
siyutiyu
- 粉丝: 1
- 资源: 26
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功