Skip to content

Instantly share code, notes, and snippets.

@Jintian
Created September 25, 2013 09:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jintian/6697255 to your computer and use it in GitHub Desktop.
Save Jintian/6697255 to your computer and use it in GitHub Desktop.
tmp
$(document).ready(function () {
editor = CodeMirror.fromTextArea(document.getElementById("sampleTextInfo"), {
lineNumbers: true,
styleActiveLine: true,
matchBrackets: true,
mode: "text/x-groovy",
theme: "solarized dark",
highlightSelectionMatches: true
});
function getSelectedRange() {
CodeMirror.commands["selectAll"](editor);
return { from: editor.getCursor(true), to: editor.getCursor(false) };
}
function autoFormatSelection() {
var range = getSelectedRange();
editor.autoFormatRange(range.from, range.to);
}
$('#formatCode').click(function () {
autoFormatSelection();
//console.log("Format");
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment