Skip to content

Instantly share code, notes, and snippets.

@louim
Created April 22, 2013 19:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save louim/5437618 to your computer and use it in GitHub Desktop.
Save louim/5437618 to your computer and use it in GitHub Desktop.
Add space around brackets and square brackets using SublimeText RegReplace
{
"replacements": {
"add_space_around_opening_brackets": {
"find": "\\((?! |\\)|\\n)",
"replace": "( ",
"greedy_scope": true,
"scope_filter": ["source.js,source.php","-comment", "-string.regexp", "-string.quoted.single.php", "-string.quoted.double.php"]
},
"add_space_around_closing_brackets": {
"find": "(?<! |\\(|\\t)\\)",
"replace": " )",
"greedy_scope": true,
"scope_filter": ["source.js,source.php","-comment", "-string.regexp", "-string.quoted.single.php", "-string.quoted.double.php"]
},
"add_space_around_square_opening_brackets": {
"find": "\\[(?! |\\]|P|\\n)",
"replace": "[ ",
"greedy_scope": true,
"scope_filter": ["source.js,source.php","-comment", "-string.regexp", "-string.quoted.single.php", "-string.quoted.double.php"]
},
"add_space_around_square_closing_brackets": {
"find": "(?<! |\\[|H|\\t)\\]",
"replace": " ]",
"greedy_scope": true,
"scope_filter": ["source.js,source.php","-comment", "-string.regexp", "-string.quoted.single.php", "-string.quoted.double.php"]
}
},
"on_save": true,
"on_save_sequences": [
{
"file_pattern": ["*.js", "*.php", "*.ctp"],
"sequence": [
"add_space_around_opening_brackets",
"add_space_around_closing_brackets",
"add_space_around_square_opening_brackets",
"add_space_around_square_closing_brackets",
"remove_trailing_spaces"
]
}
],
"results_in_panel": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment