[フレーム]
Last Updated: February 25, 2016
·
1.086K
· princemaple

Offline Code Compression -- SublimeText2 with Reg Replace Plugin

Both files should be in the User folder

In reg_replace.sublime-settings

"compress_space": {
 "find": "\t|\n",
 "replace": "",
 "greedy": true,
 "case": false,
 "scope_filter": 
 [
 "source.c, source.js, source.java, source.css",
 "-comment", "-!string"
 ]
},
"compress_comments": {
 "find": ".*?\n",
 "replace": "",
 "greedy": true,
 "case": false,
 "scope_filter": ["comment"]
},
"compress_opening_brackets": {
 "find": "(\\[|\\(|\\{)\\s+",
 "replace": "\1円",
 "greedy": true,
 "case": false,
 "scope_filter": 
 [
 "source.c, source.js, source.java, source.css",
 "-comment", "-!string"
 ]
},
"compress_closing_brackets": {
 "find": "\\s+(\\)|\\}|\\])",
 "replace": "\1円",
 "greedy": true,
 "case": false,
 "scope_filter": 
 [
 "source.c, source.js, source.java, source.css",
 "-comment", "-!string"
 ]
},
"compress_special": {
 "find": "\\s*(:|;|,)\\s*",
 "replace": "\1円",
 "greedy": true,
 "case": false,
 "scope_filter": 
 [
 "source.c, source.js, source.java, source.css",
 "-comment", "-!string"
 ]
}

In Default.sublime-commands

{
 "caption": "Reg Replace: Compress Code",
 "command": "reg_replace",
 "args": {
 "replacements": [
 "compress_comments",
 "compress_space",
 "compress_special",
 "compress_opening_brackets",
 "compress_closing_brackets"
 ]
 }
}

These have only been tested with CSS and JS files.
They should work with C and java files as well.

Any suggestions will be appreciated.

If you ask me why I would compress code when I'm offline, I don't know, I had the idea when I was on the plane. I know this might be useless. :)

AltStyle によって変換されたページ (->オリジナル) /