|
7 | 7 | ]
|
8 | 8 | },
|
9 | 9 |
|
| 10 | + // |
| 11 | + // The following key bindings enforce indentation by 2 chars in YAML frontmatter |
| 12 | + // without regards to syntax specific or global indentation settings, |
| 13 | + // to avoid YAML parsing errors. |
| 14 | + // |
| 15 | + |
| 16 | + // insert newline and indent it by two chars |
| 17 | + { "keys": ["enter"], "command": "insert_snippet", "args": { "contents": "\n" }, "context": |
| 18 | + [ |
| 19 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 20 | + { "key": "following_text", "operator": "regex_match", "operand": "^$" } |
| 21 | + ] |
| 22 | + }, |
| 23 | + // indent by one char if line starts with odd amount of spaces |
| 24 | + { "keys": ["tab"], "command": "insert", "args": { "characters": " " }, "context": |
| 25 | + [ |
| 26 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 27 | + { "key": "preceding_text", "operator": "regex_match", "operand": "(?:[ ]{2})*[ ]$" } |
| 28 | + ] |
| 29 | + }, |
| 30 | + // indent by two chars if line starts with even amount of spaces |
| 31 | + { "keys": ["tab"], "command": "insert", "args": { "characters": " " }, "context": |
| 32 | + [ |
| 33 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 34 | + { "key": "preceding_text", "operator": "regex_match", "operand": "(?:[ ]{2})*$" } |
| 35 | + ] |
| 36 | + }, |
| 37 | + // unindent by one char if line starts with odd amount of spaces |
| 38 | + { "keys": ["shift+tab"], "command": "left_delete", "context": |
| 39 | + [ |
| 40 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 41 | + { "key": "preceding_text", "operator": "regex_match", "operand": "(?:[ ]{2})*[ ]$" } |
| 42 | + ] |
| 43 | + }, |
| 44 | + // unindent by two chars if line starts with even amount of spaces |
| 45 | + { "keys": ["shift+tab"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left 2.sublime-macro"}, "context": |
| 46 | + [ |
| 47 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 48 | + { "key": "preceding_text", "operator": "regex_match", "operand": "(?:[ ]{2})*$" } |
| 49 | + ] |
| 50 | + }, |
| 51 | + // unindent by two chars if line starts with even amount of spaces |
| 52 | + { "keys": ["backspace"], "command": "run_macro_file", "args": {"file": "Packages/MarkdownEditing/macros/Delete Left 2.sublime-macro"}, "context": |
| 53 | + [ |
| 54 | + { "key": "selector", "operand": "text.html.markdown meta.frontmatter source.yaml" }, |
| 55 | + { "key": "preceding_text", "operator": "regex_match", "operand": "(?:[ ]{2})*$" } |
| 56 | + ] |
| 57 | + }, |
| 58 | + |
10 | 59 | //
|
11 | 60 | // Auto-Pairing Astersisks
|
12 | 61 | //
|
|
947 | 996 | // Unindent list item no matter of caret position if `shift_tab_unindent` is set
|
948 | 997 | { "keys": ["shift+tab"], "command": "mde_unindent_list_item", "context":
|
949 | 998 | [
|
950 |
| - { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }, |
| 999 | + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter", "match_all": true }, |
951 | 1000 | { "key": "setting.shift_tab_unindent", "operator": "equal", "operand": true },
|
952 | 1001 | { "key": "has_prev_field", "operator": "equal", "operand": false },
|
953 | 1002 | { "key": "overlay_visible", "operator": "equal", "operand": false },
|
|
957 | 1006 | // Unindent list item if caret is in front of bullets
|
958 | 1007 | { "keys": ["shift+tab"], "command": "mde_unindent_list_item", "context":
|
959 | 1008 | [
|
960 |
| - { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }, |
| 1009 | + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter", "match_all": true }, |
961 | 1010 | { "key": "has_prev_field", "operator": "equal", "operand": false },
|
962 | 1011 | { "key": "overlay_visible", "operator": "equal", "operand": false },
|
963 | 1012 | { "key": "preceding_text", "operator": "regex_match", "operand": "^[\\s>]*$", "match_all": true },
|
|
967 | 1016 | // Unindent list item if caret is behind bullets
|
968 | 1017 | { "keys": ["shift+tab"], "command": "mde_unindent_list_item", "context":
|
969 | 1018 | [
|
970 |
| - { "key": "selector", "operator": "equal", "operand": "text.html.markdown", "match_all": true }, |
| 1019 | + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter", "match_all": true }, |
971 | 1020 | { "key": "has_prev_field", "operator": "equal", "operand": false },
|
972 | 1021 | { "key": "overlay_visible", "operator": "equal", "operand": false },
|
973 | 1022 | { "key": "preceding_text", "operator": "regex_match", "operand": "^[\\s>]*[-+*]\\s*$", "match_all": true },
|
|
977 | 1026 | // Unindent list item if caret is at eol
|
978 | 1027 | { "keys": ["shift+tab"], "command": "mde_unindent_list_item", "context":
|
979 | 1028 | [
|
980 |
| - { "key": "selector", "operator": "equal", "operand": "text.html.markdown markup.list", "match_all": true }, |
| 1029 | + { "key": "selector", "operator": "equal", "operand": "text.html.markdown - meta.frontmatter", "match_all": true }, |
981 | 1030 | { "key": "has_prev_field", "operator": "equal", "operand": false },
|
982 | 1031 | { "key": "overlay_visible", "operator": "equal", "operand": false },
|
983 | 1032 | { "key": "preceding_text", "operator": "regex_contains", "operand": "^[\\s>]*[-+*]\\s", "match_all": true },
|
|
0 commit comments