michael@0: // A rough approximation of Sublime Text's keybindings michael@0: // Depends on addon/search/searchcursor.js and optionally addon/dialog/dialogs.js michael@0: michael@0: (function(mod) { michael@0: if (typeof exports == "object" && typeof module == "object") // CommonJS michael@0: mod(require("../lib/codemirror"), require("../addon/search/searchcursor"), require("../addon/edit/matchbrackets")); michael@0: else if (typeof define == "function" && define.amd) // AMD michael@0: define(["../lib/codemirror", "../addon/search/searchcursor", "../addon/edit/matchbrackets"], mod); michael@0: else // Plain browser env michael@0: mod(CodeMirror); michael@0: })(function(CodeMirror) { michael@0: "use strict"; michael@0: michael@0: var map = CodeMirror.keyMap.sublime = {fallthrough: "default"}; michael@0: var cmds = CodeMirror.commands; michael@0: var Pos = CodeMirror.Pos; michael@0: var ctrl = CodeMirror.keyMap["default"] == CodeMirror.keyMap.pcDefault ? "Ctrl-" : "Cmd-"; michael@0: michael@0: // This is not exactly Sublime's algorithm. I couldn't make heads or tails of that. michael@0: function findPosSubword(doc, start, dir) { michael@0: if (dir < 0 && start.ch == 0) return doc.clipPos(Pos(start.line - 1)); michael@0: var line = doc.getLine(start.line); michael@0: if (dir > 0 && start.ch >= line.length) return doc.clipPos(Pos(start.line + 1, 0)); michael@0: var state = "start", type; michael@0: for (var pos = start.ch, e = dir < 0 ? 0 : line.length, i = 0; pos != e; pos += dir, i++) { michael@0: var next = line.charAt(dir < 0 ? pos - 1 : pos); michael@0: var cat = next != "_" && CodeMirror.isWordChar(next) ? "w" : "o"; michael@0: if (cat == "w" && next.toUpperCase() == next) cat = "W"; michael@0: if (state == "start") { michael@0: if (cat != "o") { state = "in"; type = cat; } michael@0: } else if (state == "in") { michael@0: if (type != cat) { michael@0: if (type == "w" && cat == "W" && dir < 0) pos--; michael@0: if (type == "W" && cat == "w" && dir > 0) { type = "w"; continue; } michael@0: break; michael@0: } michael@0: } michael@0: } michael@0: return Pos(start.line, pos); michael@0: } michael@0: michael@0: function moveSubword(cm, dir) { michael@0: cm.extendSelectionsBy(function(range) { michael@0: if (cm.display.shift || cm.doc.extend || range.empty()) michael@0: return findPosSubword(cm.doc, range.head, dir); michael@0: else michael@0: return dir < 0 ? range.from() : range.to(); michael@0: }); michael@0: } michael@0: michael@0: cmds[map["Alt-Left"] = "goSubwordLeft"] = function(cm) { moveSubword(cm, -1); }; michael@0: cmds[map["Alt-Right"] = "goSubwordRight"] = function(cm) { moveSubword(cm, 1); }; michael@0: michael@0: cmds[map[ctrl + "Up"] = "scrollLineUp"] = function(cm) { michael@0: cm.scrollTo(null, cm.getScrollInfo().top - cm.defaultTextHeight()); michael@0: }; michael@0: cmds[map[ctrl + "Down"] = "scrollLineDown"] = function(cm) { michael@0: cm.scrollTo(null, cm.getScrollInfo().top + cm.defaultTextHeight()); michael@0: }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "L"] = "splitSelectionByLine"] = function(cm) { michael@0: var ranges = cm.listSelections(), lineRanges = []; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var from = ranges[i].from(), to = ranges[i].to(); michael@0: for (var line = from.line; line <= to.line; ++line) michael@0: if (!(to.line > from.line && line == to.line && to.ch == 0)) michael@0: lineRanges.push({anchor: line == from.line ? from : Pos(line, 0), michael@0: head: line == to.line ? to : Pos(line)}); michael@0: } michael@0: cm.setSelections(lineRanges, 0); michael@0: }; michael@0: michael@0: map["Shift-Tab"] = "indentLess"; michael@0: michael@0: cmds[map["Esc"] = "singleSelectionTop"] = function(cm) { michael@0: var range = cm.listSelections()[0]; michael@0: cm.setSelection(range.anchor, range.head, {scroll: false}); michael@0: }; michael@0: michael@0: cmds[map[ctrl + "L"] = "selectLine"] = function(cm) { michael@0: var ranges = cm.listSelections(), extended = []; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i]; michael@0: extended.push({anchor: Pos(range.from().line, 0), michael@0: head: Pos(range.to().line + 1, 0)}); michael@0: } michael@0: cm.setSelections(extended); michael@0: }; michael@0: michael@0: map["Shift-" + ctrl + "K"] = "deleteLine"; michael@0: michael@0: function insertLine(cm, above) { michael@0: cm.operation(function() { michael@0: var len = cm.listSelections().length, newSelection = [], last = -1; michael@0: for (var i = 0; i < len; i++) { michael@0: var head = cm.listSelections()[i].head; michael@0: if (head.line <= last) continue; michael@0: var at = Pos(head.line + (above ? 0 : 1), 0); michael@0: cm.replaceRange("\n", at, null, "+insertLine"); michael@0: cm.indentLine(at.line, null, true); michael@0: newSelection.push({head: at, anchor: at}); michael@0: last = head.line + 1; michael@0: } michael@0: cm.setSelections(newSelection); michael@0: }); michael@0: } michael@0: michael@0: cmds[map[ctrl + "Enter"] = "insertLineAfter"] = function(cm) { insertLine(cm, false); }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "Enter"] = "insertLineBefore"] = function(cm) { insertLine(cm, true); }; michael@0: michael@0: function wordAt(cm, pos) { michael@0: var start = pos.ch, end = start, line = cm.getLine(pos.line); michael@0: while (start && CodeMirror.isWordChar(line.charAt(start - 1))) --start; michael@0: while (end < line.length && CodeMirror.isWordChar(line.charAt(end))) ++end; michael@0: return {from: Pos(pos.line, start), to: Pos(pos.line, end), word: line.slice(start, end)}; michael@0: } michael@0: michael@0: cmds[map[ctrl + "D"] = "selectNextOccurrence"] = function(cm) { michael@0: var from = cm.getCursor("from"), to = cm.getCursor("to"); michael@0: var fullWord = cm.state.sublimeFindFullWord == cm.doc.sel; michael@0: if (CodeMirror.cmpPos(from, to) == 0) { michael@0: var word = wordAt(cm, from); michael@0: if (!word.word) return; michael@0: cm.setSelection(word.from, word.to); michael@0: fullWord = true; michael@0: } else { michael@0: var text = cm.getRange(from, to); michael@0: var query = fullWord ? new RegExp("\\b" + text + "\\b") : text; michael@0: var cur = cm.getSearchCursor(query, to); michael@0: if (cur.findNext()) { michael@0: cm.addSelection(cur.from(), cur.to()); michael@0: } else { michael@0: cur = cm.getSearchCursor(query, Pos(cm.firstLine(), 0)); michael@0: if (cur.findNext()) michael@0: cm.addSelection(cur.from(), cur.to()); michael@0: } michael@0: } michael@0: if (fullWord) michael@0: cm.state.sublimeFindFullWord = cm.doc.sel; michael@0: }; michael@0: michael@0: var mirror = "(){}[]"; michael@0: function selectBetweenBrackets(cm) { michael@0: var pos = cm.getCursor(), opening = cm.scanForBracket(pos, -1); michael@0: if (!opening) return; michael@0: for (;;) { michael@0: var closing = cm.scanForBracket(pos, 1); michael@0: if (!closing) return; michael@0: if (closing.ch == mirror.charAt(mirror.indexOf(opening.ch) + 1)) { michael@0: cm.setSelection(Pos(opening.pos.line, opening.pos.ch + 1), closing.pos, false); michael@0: return true; michael@0: } michael@0: pos = Pos(closing.pos.line, closing.pos.ch + 1); michael@0: } michael@0: } michael@0: michael@0: cmds[map["Shift-" + ctrl + "Space"] = "selectScope"] = function(cm) { michael@0: selectBetweenBrackets(cm) || cm.execCommand("selectAll"); michael@0: }; michael@0: cmds[map["Shift-" + ctrl + "M"] = "selectBetweenBrackets"] = function(cm) { michael@0: if (!selectBetweenBrackets(cm)) return CodeMirror.Pass; michael@0: }; michael@0: michael@0: cmds[map[ctrl + "M"] = "goToBracket"] = function(cm) { michael@0: cm.extendSelectionsBy(function(range) { michael@0: var next = cm.scanForBracket(range.head, 1); michael@0: if (next && CodeMirror.cmpPos(next.pos, range.head) != 0) return next.pos; michael@0: var prev = cm.scanForBracket(range.head, -1); michael@0: return prev && Pos(prev.pos.line, prev.pos.ch + 1) || range.head; michael@0: }); michael@0: }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "Up"] = "swapLineUp"] = function(cm) { michael@0: var ranges = cm.listSelections(), linesToMove = [], at = cm.firstLine() - 1; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i], from = range.from().line - 1, to = range.to().line; michael@0: if (from > at) linesToMove.push(from, to); michael@0: else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; michael@0: at = to; michael@0: } michael@0: cm.operation(function() { michael@0: for (var i = 0; i < linesToMove.length; i += 2) { michael@0: var from = linesToMove[i], to = linesToMove[i + 1]; michael@0: var line = cm.getLine(from); michael@0: cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); michael@0: if (to > cm.lastLine()) { michael@0: cm.replaceRange("\n" + line, Pos(cm.lastLine()), null, "+swapLine"); michael@0: var sels = cm.listSelections(), last = sels[sels.length - 1]; michael@0: var head = last.head.line == to ? Pos(to - 1) : last.head; michael@0: var anchor = last.anchor.line == to ? Pos(to - 1) : last.anchor; michael@0: cm.setSelections(sels.slice(0, sels.length - 1).concat([{head: head, anchor: anchor}])); michael@0: } else { michael@0: cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); michael@0: } michael@0: } michael@0: cm.scrollIntoView(); michael@0: }); michael@0: }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "Down"] = "swapLineDown"] = function(cm) { michael@0: var ranges = cm.listSelections(), linesToMove = [], at = cm.lastLine() + 1; michael@0: for (var i = ranges.length - 1; i >= 0; i--) { michael@0: var range = ranges[i], from = range.to().line + 1, to = range.from().line; michael@0: if (from < at) linesToMove.push(from, to); michael@0: else if (linesToMove.length) linesToMove[linesToMove.length - 1] = to; michael@0: at = to; michael@0: } michael@0: cm.operation(function() { michael@0: for (var i = linesToMove.length - 2; i >= 0; i -= 2) { michael@0: var from = linesToMove[i], to = linesToMove[i + 1]; michael@0: var line = cm.getLine(from); michael@0: if (from == cm.lastLine()) michael@0: cm.replaceRange("", Pos(from - 1), Pos(from), "+swapLine"); michael@0: else michael@0: cm.replaceRange("", Pos(from, 0), Pos(from + 1, 0), "+swapLine"); michael@0: cm.replaceRange(line + "\n", Pos(to, 0), null, "+swapLine"); michael@0: } michael@0: cm.scrollIntoView(); michael@0: }); michael@0: }; michael@0: michael@0: map[ctrl + "/"] = "toggleComment"; michael@0: michael@0: cmds[map[ctrl + "J"] = "joinLines"] = function(cm) { michael@0: var ranges = cm.listSelections(), joined = []; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i], from = range.from(); michael@0: var start = from.line, end = range.to().line; michael@0: while (i < ranges.length - 1 && ranges[i + 1].from().line == end) michael@0: end = ranges[++i].to().line; michael@0: joined.push({start: start, end: end, anchor: !range.empty() && from}); michael@0: } michael@0: cm.operation(function() { michael@0: var offset = 0, ranges = []; michael@0: for (var i = 0; i < joined.length; i++) { michael@0: var obj = joined[i]; michael@0: var anchor = obj.anchor && Pos(obj.anchor.line - offset, obj.anchor.ch), head; michael@0: for (var line = obj.start; line <= obj.end; line++) { michael@0: var actual = line - offset; michael@0: if (line == obj.end) head = Pos(actual, cm.getLine(actual).length + 1); michael@0: if (actual < cm.lastLine()) { michael@0: cm.replaceRange(" ", Pos(actual), Pos(actual + 1, /^\s*/.exec(cm.getLine(actual + 1))[0].length)); michael@0: ++offset; michael@0: } michael@0: } michael@0: ranges.push({anchor: anchor || head, head: head}); michael@0: } michael@0: cm.setSelections(ranges, 0); michael@0: }); michael@0: }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "D"] = "duplicateLine"] = function(cm) { michael@0: cm.operation(function() { michael@0: var rangeCount = cm.listSelections().length; michael@0: for (var i = 0; i < rangeCount; i++) { michael@0: var range = cm.listSelections()[i]; michael@0: if (range.empty()) michael@0: cm.replaceRange(cm.getLine(range.head.line) + "\n", Pos(range.head.line, 0)); michael@0: else michael@0: cm.replaceRange(cm.getRange(range.from(), range.to()), range.from()); michael@0: } michael@0: cm.scrollIntoView(); michael@0: }); michael@0: }; michael@0: michael@0: map[ctrl + "T"] = "transposeChars"; michael@0: michael@0: function sortLines(cm, caseSensitive) { michael@0: var ranges = cm.listSelections(), toSort = [], selected; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i]; michael@0: if (range.empty()) continue; michael@0: var from = range.from().line, to = range.to().line; michael@0: while (i < ranges.length - 1 && ranges[i + 1].from().line == to) michael@0: to = range[++i].to().line; michael@0: toSort.push(from, to); michael@0: } michael@0: if (toSort.length) selected = true; michael@0: else toSort.push(cm.firstLine(), cm.lastLine()); michael@0: michael@0: cm.operation(function() { michael@0: var ranges = []; michael@0: for (var i = 0; i < toSort.length; i += 2) { michael@0: var from = toSort[i], to = toSort[i + 1]; michael@0: var start = Pos(from, 0), end = Pos(to); michael@0: var lines = cm.getRange(start, end, false); michael@0: if (caseSensitive) michael@0: lines.sort(); michael@0: else michael@0: lines.sort(function(a, b) { michael@0: var au = a.toUpperCase(), bu = b.toUpperCase(); michael@0: if (au != bu) { a = au; b = bu; } michael@0: return a < b ? -1 : a == b ? 0 : 1; michael@0: }); michael@0: cm.replaceRange(lines, start, end); michael@0: if (selected) ranges.push({anchor: start, head: end}); michael@0: } michael@0: if (selected) cm.setSelections(ranges, 0); michael@0: }); michael@0: } michael@0: michael@0: cmds[map["F9"] = "sortLines"] = function(cm) { sortLines(cm, true); }; michael@0: cmds[map[ctrl + "F9"] = "sortLinesInsensitive"] = function(cm) { sortLines(cm, false); }; michael@0: michael@0: cmds[map["F2"] = "nextBookmark"] = function(cm) { michael@0: var marks = cm.state.sublimeBookmarks; michael@0: if (marks) while (marks.length) { michael@0: var current = marks.shift(); michael@0: var found = current.find(); michael@0: if (found) { michael@0: marks.push(current); michael@0: return cm.setSelection(found.from, found.to); michael@0: } michael@0: } michael@0: }; michael@0: michael@0: cmds[map["Shift-F2"] = "prevBookmark"] = function(cm) { michael@0: var marks = cm.state.sublimeBookmarks; michael@0: if (marks) while (marks.length) { michael@0: marks.unshift(marks.pop()); michael@0: var found = marks[marks.length - 1].find(); michael@0: if (!found) michael@0: marks.pop(); michael@0: else michael@0: return cm.setSelection(found.from, found.to); michael@0: } michael@0: }; michael@0: michael@0: cmds[map[ctrl + "F2"] = "toggleBookmark"] = function(cm) { michael@0: var ranges = cm.listSelections(); michael@0: var marks = cm.state.sublimeBookmarks || (cm.state.sublimeBookmarks = []); michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var from = ranges[i].from(), to = ranges[i].to(); michael@0: var found = cm.findMarks(from, to); michael@0: for (var j = 0; j < found.length; j++) { michael@0: if (found[j].sublimeBookmark) { michael@0: found[j].clear(); michael@0: for (var k = 0; k < marks.length; k++) michael@0: if (marks[k] == found[j]) michael@0: marks.splice(k--, 1); michael@0: break; michael@0: } michael@0: } michael@0: if (j == found.length) michael@0: marks.push(cm.markText(from, to, {sublimeBookmark: true, clearWhenEmpty: false})); michael@0: } michael@0: }; michael@0: michael@0: cmds[map["Shift-" + ctrl + "F2"] = "clearBookmarks"] = function(cm) { michael@0: var marks = cm.state.sublimeBookmarks; michael@0: if (marks) for (var i = 0; i < marks.length; i++) marks[i].clear(); michael@0: marks.length = 0; michael@0: }; michael@0: michael@0: cmds[map["Alt-F2"] = "selectBookmarks"] = function(cm) { michael@0: var marks = cm.state.sublimeBookmarks, ranges = []; michael@0: if (marks) for (var i = 0; i < marks.length; i++) { michael@0: var found = marks[i].find(); michael@0: if (!found) michael@0: marks.splice(i--, 0); michael@0: else michael@0: ranges.push({anchor: found.from, head: found.to}); michael@0: } michael@0: if (ranges.length) michael@0: cm.setSelections(ranges, 0); michael@0: }; michael@0: michael@0: map["Alt-Q"] = "wrapLines"; michael@0: michael@0: var mapK = CodeMirror.keyMap["sublime-Ctrl-K"] = {auto: "sublime", nofallthrough: true}; michael@0: michael@0: map[ctrl + "K"] = function(cm) {cm.setOption("keyMap", "sublime-Ctrl-K");}; michael@0: michael@0: function modifyWordOrSelection(cm, mod) { michael@0: cm.operation(function() { michael@0: var ranges = cm.listSelections(), indices = [], replacements = []; michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i]; michael@0: if (range.empty()) { indices.push(i); replacements.push(""); } michael@0: else replacements.push(mod(cm.getRange(range.from(), range.to()))); michael@0: } michael@0: cm.replaceSelections(replacements, "around", "case"); michael@0: for (var i = indices.length - 1, at; i >= 0; i--) { michael@0: var range = ranges[indices[i]]; michael@0: if (at && CodeMirror.cmpPos(range.head, at) > 0) continue; michael@0: var word = wordAt(cm, range.head); michael@0: at = word.from; michael@0: cm.replaceRange(mod(word.word), word.from, word.to); michael@0: } michael@0: }); michael@0: } michael@0: michael@0: mapK[ctrl + "Backspace"] = "delLineLeft"; michael@0: michael@0: cmds[mapK[ctrl + "K"] = "delLineRight"] = function(cm) { michael@0: cm.operation(function() { michael@0: var ranges = cm.listSelections(); michael@0: for (var i = ranges.length - 1; i >= 0; i--) michael@0: cm.replaceRange("", ranges[i].anchor, Pos(ranges[i].to().line), "+delete"); michael@0: cm.scrollIntoView(); michael@0: }); michael@0: }; michael@0: michael@0: cmds[mapK[ctrl + "U"] = "upcaseAtCursor"] = function(cm) { michael@0: modifyWordOrSelection(cm, function(str) { return str.toUpperCase(); }); michael@0: }; michael@0: cmds[mapK[ctrl + "L"] = "downcaseAtCursor"] = function(cm) { michael@0: modifyWordOrSelection(cm, function(str) { return str.toLowerCase(); }); michael@0: }; michael@0: michael@0: cmds[mapK[ctrl + "Space"] = "setSublimeMark"] = function(cm) { michael@0: if (cm.state.sublimeMark) cm.state.sublimeMark.clear(); michael@0: cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); michael@0: }; michael@0: cmds[mapK[ctrl + "A"] = "selectToSublimeMark"] = function(cm) { michael@0: var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); michael@0: if (found) cm.setSelection(cm.getCursor(), found); michael@0: }; michael@0: cmds[mapK[ctrl + "W"] = "deleteToSublimeMark"] = function(cm) { michael@0: var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); michael@0: if (found) { michael@0: var from = cm.getCursor(), to = found; michael@0: if (CodeMirror.cmpPos(from, to) > 0) { var tmp = to; to = from; from = tmp; } michael@0: cm.state.sublimeKilled = cm.getRange(from, to); michael@0: cm.replaceRange("", from, to); michael@0: } michael@0: }; michael@0: cmds[mapK[ctrl + "X"] = "swapWithSublimeMark"] = function(cm) { michael@0: var found = cm.state.sublimeMark && cm.state.sublimeMark.find(); michael@0: if (found) { michael@0: cm.state.sublimeMark.clear(); michael@0: cm.state.sublimeMark = cm.setBookmark(cm.getCursor()); michael@0: cm.setCursor(found); michael@0: } michael@0: }; michael@0: cmds[mapK[ctrl + "Y"] = "sublimeYank"] = function(cm) { michael@0: if (cm.state.sublimeKilled != null) michael@0: cm.replaceSelection(cm.state.sublimeKilled, null, "paste"); michael@0: }; michael@0: michael@0: mapK[ctrl + "G"] = "clearBookmarks"; michael@0: cmds[mapK[ctrl + "C"] = "showInCenter"] = function(cm) { michael@0: var pos = cm.cursorCoords(null, "local"); michael@0: cm.scrollTo(null, (pos.top + pos.bottom) / 2 - cm.getScrollInfo().clientHeight / 2); michael@0: }; michael@0: michael@0: cmds[map["Shift-Alt-Up"] = "selectLinesUpward"] = function(cm) { michael@0: cm.operation(function() { michael@0: var ranges = cm.listSelections(); michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i]; michael@0: if (range.head.line > cm.firstLine()) michael@0: cm.addSelection(Pos(range.head.line - 1, range.head.ch)); michael@0: } michael@0: }); michael@0: }; michael@0: cmds[map["Shift-Alt-Down"] = "selectLinesDownward"] = function(cm) { michael@0: cm.operation(function() { michael@0: var ranges = cm.listSelections(); michael@0: for (var i = 0; i < ranges.length; i++) { michael@0: var range = ranges[i]; michael@0: if (range.head.line < cm.lastLine()) michael@0: cm.addSelection(Pos(range.head.line + 1, range.head.ch)); michael@0: } michael@0: }); michael@0: }; michael@0: michael@0: function findAndGoTo(cm, forward) { michael@0: var from = cm.getCursor("from"), to = cm.getCursor("to"); michael@0: if (CodeMirror.cmpPos(from, to) == 0) { michael@0: var word = wordAt(cm, from); michael@0: if (!word.word) return; michael@0: from = word.from; michael@0: to = word.to; michael@0: } michael@0: michael@0: var query = cm.getRange(from, to); michael@0: var cur = cm.getSearchCursor(query, forward ? to : from); michael@0: michael@0: if (forward ? cur.findNext() : cur.findPrevious()) { michael@0: cm.setSelection(cur.from(), cur.to()); michael@0: } else { michael@0: cur = cm.getSearchCursor(query, forward ? Pos(cm.firstLine(), 0) michael@0: : cm.clipPos(Pos(cm.lastLine()))); michael@0: if (forward ? cur.findNext() : cur.findPrevious()) michael@0: cm.setSelection(cur.from(), cur.to()); michael@0: else if (word) michael@0: cm.setSelection(from, to); michael@0: } michael@0: }; michael@0: cmds[map[ctrl + "F3"] = "findUnder"] = function(cm) { findAndGoTo(cm, true); }; michael@0: cmds[map["Shift-" + ctrl + "F3"] = "findUnderPrevious"] = function(cm) { findAndGoTo(cm,false); }; michael@0: michael@0: map["Shift-" + ctrl + "["] = "fold"; michael@0: map["Shift-" + ctrl + "]"] = "unfold"; michael@0: mapK[ctrl + "0"] = mapK[ctrl + "j"] = "unfoldAll"; michael@0: michael@0: map[ctrl + "I"] = "findIncremental"; michael@0: map["Shift-" + ctrl + "I"] = "findIncrementalReverse"; michael@0: map[ctrl + "H"] = "replace"; michael@0: map["F3"] = "findNext"; michael@0: map["Shift-F3"] = "findPrev"; michael@0: michael@0: });