Default.sublime-keymap (7879B)
1 [ 2 // Add a colon followed by space and semicolon after a property name, 3 // if the next following token doesn't look like a value. 4 { "keys": [":"], "command": "insert_snippet", "args": {"contents": ": $0;"}, "context": 5 [ 6 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 7 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 8 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 9 { "key": "preceding_text", "operator": "regex_contains", "operand": "\\w$", "match_all": false }, 10 { "key": "following_text", "operator": "regex_contains", "operand": "^\\s*($|[^:;}]+:)", "match_all": false } 11 ] 12 }, 13 // Add a colon followed by space after a property name, 14 // if the next character is a semicolon or the following token looks like a value. 15 { "keys": [":"], "command": "insert_snippet", "args": {"contents": ": $0"}, "context": 16 [ 17 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 18 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 19 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 20 { "key": "preceding_text", "operator": "regex_contains", "operand": "\\w$", "match_all": false }, 21 { "key": "following_text", "operator": "regex_contains", "operand": "^;|^[^\\s:;][^:]*($|[;}]|//|/\\*)", "match_all": true } 22 ] 23 }, 24 // Move the cursor to prevent adding a duplicated semicolon. 25 { "keys": [";"], "command": "move", "args": {"by": "characters", "forward": true}, "context": 26 [ 27 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 28 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 29 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 30 { "key": "following_text", "operator": "regex_contains", "operand": "^;", "match_all": false } 31 ] 32 }, 33 // Delete both the colon on the left and a semicolon on the right. 34 { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": 35 [ 36 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 37 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 38 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 39 { "key": "preceding_text", "operator": "regex_contains", "operand": ":$", "match_all": false }, 40 { "key": "following_text", "operator": "regex_contains", "operand": "^;", "match_all": false } 41 ] 42 }, 43 // Move the caret to the next line and leave the terminating semicolon untouched. 44 // This is to not bother with semicolons even though completions end up with the caret directy in front of it. 45 { "keys": ["enter"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Add Line.sublime-macro"} , "context": 46 [ 47 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 48 { "key": "auto_complete_visible", "operator": "equal", "operand": false }, 49 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 50 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 51 { "key": "preceding_text", "operator": "not_regex_contains", "operand": ";\\s*$", "match_all": false }, 52 { "key": "following_text", "operator": "regex_contains", "operand": "^\\s*;", "match_all": false } 53 ] 54 }, 55 56 // Expand {|} to { | } when space is pressed 57 { "keys": [" "], "command": "insert_snippet", "args": {"contents": " $0 "}, "context": 58 [ 59 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 60 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 61 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 62 { "key": "preceding_text", "operator": "regex_contains", "operand": "\\{$", "match_all": true }, 63 { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true } 64 ] 65 }, 66 { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": 67 [ 68 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 69 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 70 { "key": "selector", "operator": "equal", "operand": "source.css - meta.selector.css", "match_all": true }, 71 { "key": "preceding_text", "operator": "regex_contains", "operand": "\\{ $", "match_all": true }, 72 { "key": "following_text", "operator": "regex_contains", "operand": "^ \\}", "match_all": true } 73 ] 74 }, 75 76 // Expand /*|*/ to /* | */ when space is pressed 77 { "keys": [" "], "command": "insert_snippet", "args": {"contents": " $0 "}, "context": 78 [ 79 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 80 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 81 { "key": "selector", "operator": "equal", "operand": "source.css comment", "match_all": true }, 82 { "key": "preceding_text", "operator": "regex_contains", "operand": "/\\*$", "match_all": true }, 83 { "key": "following_text", "operator": "regex_contains", "operand": "^\\*/", "match_all": true } 84 ] 85 }, 86 { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Left Right.sublime-macro"}, "context": 87 [ 88 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 89 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 90 { "key": "selector", "operator": "equal", "operand": "source.css comment", "match_all": true }, 91 { "key": "preceding_text", "operator": "regex_contains", "operand": "/\\* $", "match_all": true }, 92 { "key": "following_text", "operator": "regex_contains", "operand": "^ \\*/", "match_all": true } 93 ] 94 }, 95 96 // Auto-pair double quotes (also if followed by comma or semicolon) 97 // Example: key: |; -> key: "|"; 98 { "keys": ["\""], "command": "insert_snippet", "args": {"contents": "\"$0\""}, "context": 99 [ 100 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 101 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 102 { "key": "selector", "operator": "equal", "operand": "source.css - string", "match_all": true }, 103 { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|,|;|$)", "match_all": true }, 104 { "key": "preceding_text", "operator": "not_regex_contains", "operand": "[\"a-zA-Z0-9_]$", "match_all": true }, 105 { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.double - punctuation.definition.string.end", "match_all": true } 106 ] 107 }, 108 109 // Auto-pair single quotes (also if followed by comma or semicolon) 110 // Example: key: |; -> key: '|'; 111 { "keys": ["'"], "command": "insert_snippet", "args": {"contents": "'$0'"}, "context": 112 [ 113 { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true }, 114 { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true }, 115 { "key": "selector", "operator": "equal", "operand": "source.css - string", "match_all": true }, 116 { "key": "following_text", "operator": "regex_contains", "operand": "^(?:\t| |\\)|]|\\}|>|,|;|$)", "match_all": true }, 117 { "key": "preceding_text", "operator": "not_regex_contains", "operand": "['a-zA-Z0-9_]$", "match_all": true }, 118 { "key": "eol_selector", "operator": "not_equal", "operand": "string.quoted.single - punctuation.definition.string.end", "match_all": true } 119 ] 120 } 121 ]