-
-
Save ofen/044b8b4674b737486cbd6b55f42cd724 to your computer and use it in GitHub Desktop.
Surround with backticks in Sublime Text 3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Copy the following into Preferences > Key Bindings -- User | |
// Thanks to: | |
// http://sublimetext.userecho.com/topic/86166-backtick-quoting-selected-text-does-not-work-like-single-quotes-and-double-quotes/ | |
[ | |
{ | |
"keys": [ | |
"`" | |
], | |
"command": "insert_snippet", | |
"args": { | |
"contents": "`$0`" | |
}, | |
"context": [ | |
{ | |
"key": "setting.auto_match_enabled", | |
"operator": "equal", | |
"operand": true | |
}, | |
{ | |
"key": "selection_empty", | |
"operator": "equal", | |
"operand": true, | |
"match_all": true | |
}, | |
{ | |
"key": "following_text", | |
"operator": "regex_contains", | |
"operand": "^(?:\t| |\\)|]|\\}|>|$)", | |
"match_all": true | |
}, | |
{ | |
"key": "preceding_text", | |
"operator": "not_regex_contains", | |
"operand": "[`a-zA-Z0-9_]$", | |
"match_all": true | |
}, | |
{ | |
"key": "eol_selector", | |
"operator": "not_equal", | |
"operand": "string.quoted.single", | |
"match_all": true | |
} | |
] | |
}, | |
{ | |
"keys": [ | |
"`" | |
], | |
"command": "insert_snippet", | |
"args": { | |
"contents": "`${0:$SELECTION}`" | |
}, | |
"context": [ | |
{ | |
"key": "setting.auto_match_enabled", | |
"operator": "equal", | |
"operand": true | |
}, | |
{ | |
"key": "selection_empty", | |
"operator": "equal", | |
"operand": false, | |
"match_all": true | |
} | |
] | |
}, | |
{ | |
"keys": [ | |
"`" | |
], | |
"command": "move", | |
"args": { | |
"by": "characters", | |
"forward": true | |
}, | |
"context": [ | |
{ | |
"key": "setting.auto_match_enabled", | |
"operator": "equal", | |
"operand": true | |
}, | |
{ | |
"key": "selection_empty", | |
"operator": "equal", | |
"operand": true, | |
"match_all": true | |
}, | |
{ | |
"key": "following_text", | |
"operator": "regex_contains", | |
"operand": "^`", | |
"match_all": true | |
} | |
] | |
}, | |
{ | |
"keys": [ | |
"backspace" | |
], | |
"command": "run_macro_file", | |
"args": { | |
"file": "res://Packages/Default/Delete Left Right.sublime-macro" | |
}, | |
"context": [ | |
{ | |
"key": "setting.auto_match_enabled", | |
"operator": "equal", | |
"operand": true | |
}, | |
{ | |
"key": "selection_empty", | |
"operator": "equal", | |
"operand": true, | |
"match_all": true | |
}, | |
{ | |
"key": "preceding_text", | |
"operator": "regex_contains", | |
"operand": "`$", | |
"match_all": true | |
}, | |
{ | |
"key": "following_text", | |
"operator": "regex_contains", | |
"operand": "^`", | |
"match_all": true | |
} | |
] | |
} | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment