Created
June 2, 2014 16:54
-
-
Save Naatan/99abd413394f10dd994d to your computer and use it in GitHub Desktop.
Select Brace Contents
This file contains 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
(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(); | |
})(); |
This file contains 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
{ | |
"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