Skip to content

Instantly share code, notes, and snippets.

@Naatan
Created June 2, 2014 16:54
Show Gist options
  • Save Naatan/99abd413394f10dd994d to your computer and use it in GitHub Desktop.
Save Naatan/99abd413394f10dd994d to your computer and use it in GitHub Desktop.
Select Brace Contents
(function() {
var sm = ko.views.manager.currentView.scimoz;
function selBraceContents()
{
ko.commands.doCommand('cmd_selectToMatchingBrace');
var selText = sm.selText;
if (selText == '') {
sm.searchAnchor(sm.currentPos);
var pos = sm.searchPrev(null, '<');
if (pos != -1) {
sm.gotoPos(pos);
return selBraceContents();
} else {
return;
}
}
var startPos = selText.indexOf('>') + 1;
var endPos = selText.substr(1, selText.length).indexOf('<') + 1;
var pos = sm.selectionStart;
sm.setSel(pos + startPos, pos + endPos);
}
selBraceContents();
})();
{
"keyboard_shortcut": "",
"name": "Select Brace Contents",
"language": "JavaScript",
"trigger": "trigger_postopen",
"trigger_enabled": false,
"value": [
"(function() {",
"",
"var sm = ko.views.manager.currentView.scimoz;",
"",
"function selBraceContents()",
"{",
"",
" ko.commands.doCommand('cmd_selectToMatchingBrace');",
" var selText = sm.selText;",
"",
" if (selText == '') {",
" sm.searchAnchor(sm.currentPos);",
" var pos = sm.searchPrev(null, '<');",
" ",
" if (pos != -1) {",
" sm.gotoPos(pos);",
" return selBraceContents();",
" } else {",
" return;",
" }",
" }",
"",
" var startPos = selText.indexOf('>') + 1;",
" var endPos = selText.substr(1, selText.length).indexOf('<') + 1;",
"",
" var pos = sm.selectionStart;",
" sm.setSel(pos + startPos, pos + endPos);",
"",
"}",
"",
"selBraceContents();",
"",
"})();"
],
"version": "1.0.12",
"rank": 100,
"async": false,
"type": "macro",
"icon": "chrome://icomoon/skin/icons/quotes-right3.png"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment